This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / configs / retiolum.nix
4.5 kB 129 lines
1{ 2 self, 3 config, 4 pkgs, 5 lib, 6 ... 7}: 8 9let 10 tincr = self.packages.${pkgs.system}.tincr; 11 tincrPkg = pkgs.runCommand "tincr-sbin-${tincr.version}" { version = tincr.version; } '' 12 mkdir -p $out 13 cp -r ${tincr}/* $out/ 14 chmod -R u+w $out 15 ln -s bin $out/sbin 16 ''; 17 18 # Peer keys and addresses come straight from kartei. This is only the host 19 # database -- the daemon stays on nixpkgs' services.tinc with pkgs/tincr 20 # swapped in (barnacle does the same with tincr's darwin module, see 21 # machines/barnacle/retiolum.nix). 22 # 23 # tincHosts is already filtered to SPTPS-capable nodes, so the RSA-only 24 # leftovers tincr refuses per connection attempt are gone. 25 kartei = import (self.inputs.kartei + "/modules/retiolum/hosts.nix") { inherit lib; }; 26 27 name = config.networking.hostName; 28 29 # Nodes with no kartei card, known only inside superconfig. Exposes the same 30 # interface as kartei's hosts.nix, so both sources merge the same way. 31 local = self.retiolum; 32 33 own = kartei.own.${name} or local.own.${name}; 34in 35 36{ 37 38 networking.firewall.allowedTCPPorts = [ 655 ]; 39 networking.firewall.allowedUDPPorts = [ 655 ]; 40 41 services.tinc.networks.retiolum = { 42 package = tincrPkg; 43 # 1+ maps to per-packet Debug/Trace in tincr, which floods journald 44 # (tens of thousands of suppressed messages per minute) and rotates 45 # all other units' logs out of the journal within hours 46 debugLevel = 0; 47 hosts = kartei.tincHosts // local.tincHosts; 48 extraConfig = '' 49 AutoConnect = yes 50 LocalDiscovery = yes 51 ''; 52 settings = { 53 Interface = "retiolum"; 54 Name = name; 55 ConnectTo = [ 56 "neoprism" 57 "ni" 58 "eve" 59 ]; 60 }; 61 }; 62 63 # A changed tinc unit is restarted in switch-to-configuration's start phase 64 # instead of stopped up front: otherwise retiolum stays down for the whole 65 # stop phase (minutes when a unit like ipfs waits out its stop timeout) and 66 # takes the deploying ssh session over <machine>.r with it. 67 systemd.services."tinc.retiolum".stopIfChanged = false; 68 69 # debugLevel 0 is still Info, and reconnect/MTU/path-revalidation chatter 70 # at Info floods journald; keep Warn and Error only. Target-scoped on 71 # purpose: `-d 0` sets the global directive and replaces a bare 72 # RUST_LOG=warn, while `tinc` prefix-matches every tinc* crate's target. 73 systemd.services."tinc.retiolum".environment.RUST_LOG = "tinc=warn"; 74 75 # Copy keys into the tinc config directory before tinc starts. 76 # Running before nixpkgs' preStart ensures key generation is skipped. 77 systemd.services."tinc.retiolum".preStart = lib.mkBefore '' 78 rm -f /etc/tinc/retiolum/rsa_key.priv /etc/tinc/retiolum/ed25519_key.priv /etc/tinc/retiolum/tinc-up 79 cp ${ 80 config.clan.core.vars.generators.retiolum.files."retiolum.rsa_key.priv".path 81 } /etc/tinc/retiolum/rsa_key.priv 82 cp ${ 83 config.clan.core.vars.generators.retiolum.files."retiolum.ed25519_key.priv".path 84 } /etc/tinc/retiolum/ed25519_key.priv 85 chown tinc-retiolum /etc/tinc/retiolum/rsa_key.priv /etc/tinc/retiolum/ed25519_key.priv 86 chmod 600 /etc/tinc/retiolum/rsa_key.priv /etc/tinc/retiolum/ed25519_key.priv 87 ''; 88 89 clan.core.vars.generators.retiolum = { 90 files."retiolum.rsa_key.priv" = { }; 91 files."retiolum.ed25519_key.priv" = { }; 92 files."retiolum.rsa_key.pub".secret = false; 93 files."retiolum.ed25519_key.pub".secret = false; 94 runtimeInputs = with pkgs; [ 95 coreutils 96 tinc_pre 97 ]; 98 script = '' 99 tinc --config "$out" generate-keys 4096 >/dev/null 100 mv "$out"/rsa_key.priv "$out"/retiolum.rsa_key.priv 101 mv "$out"/ed25519_key.priv "$out"/retiolum.ed25519_key.priv 102 mv "$out"/rsa_key.pub "$out"/retiolum.rsa_key.pub 103 mv "$out"/ed25519_key.pub "$out"/retiolum.ed25519_key.pub 104 ''; 105 }; 106 107 systemd.network.networks.retiolum = { 108 matchConfig.Name = "retiolum"; 109 address = lib.optional (own.ip4 != null) "${own.ip4}/16" ++ [ "${own.ip6}/16" ]; 110 linkConfig = { 111 MTUBytes = "1377"; 112 RequiredForOnline = "no"; 113 }; 114 networkConfig = { 115 LinkLocalAddressing = "no"; 116 }; 117 }; 118 119 environment.systemPackages = [ 120 tincrPkg 121 ]; 122 123 # Upstream nixos/tinc preStart chowns hosts/ and invitations/ but not 124 # the network dir itself, so tincr (and tinc 1.1pre18) can't persist 125 # its address-cache there. Drop this once nixpkgs#520533 lands. 126 systemd.tmpfiles.rules = [ 127 "z /etc/tinc/retiolum 0755 tinc-retiolum - -" 128 ]; 129}