This repository has no description
2.0 kB
73 lines
1{ self, config, lib, pkgs, ... }:
2let
3 peers = [
4 ### official servers
5 "tcp://188.40.132.242:9651" # DE 01
6 "tcp://[2a01:4f8:221:1e0b::2]:9651"
7 "quic://188.40.132.242:9651"
8 "quic://[2a01:4f8:221:1e0b::2]:9651"
9
10 "tcp://136.243.47.186:9651" # DE 02
11 "tcp://[2a01:4f8:212:fa6::2]:9651"
12 "quic://136.243.47.186:9651"
13 "quic://[2a01:4f8:212:fa6::2]:9651"
14
15 "tcp://185.69.166.7:9651" # BE 03
16 "tcp://[2a02:1802:5e:0:8478:51ff:fee2:3331]:9651"
17 "quic://185.69.166.7:9651"
18 "quic://[2a02:1802:5e:0:8478:51ff:fee2:3331]:9651"
19
20 "tcp://185.69.166.8:9651" # BE 04
21 "tcp://[2a02:1802:5e:0:8c9e:7dff:fec9:f0d2]:9651"
22 "quic://185.69.166.8:9651"
23 "quic://[2a02:1802:5e:0:8c9e:7dff:fec9:f0d2]:9651"
24
25 "tcp://65.21.231.58:9651" # FI 05
26 "tcp://[2a01:4f9:6a:1dc5::2]:9651"
27 "quic://65.21.231.58:9651"
28 "quic://[2a01:4f9:6a:1dc5::2]:9651"
29
30 "tcp://65.109.18.113:9651" # FI 06
31 "tcp://[2a01:4f9:5a:1042::2]:9651"
32 "quic://65.109.18.113:9651"
33 "quic://[2a01:4f9:5a:1042::2]:9651"
34 ];
35in
36{
37 networking.firewall.allowedTCPPorts = [ 9651 ];
38 networking.firewall.allowedUDPPorts = [ 9650 9651 ];
39
40 systemd.services.mycelium = {
41 description = "Mycelium network";
42 wantedBy = [ "multi-user.target" ];
43
44 serviceConfig = {
45 ExecStart = lib.concatStringsSep " " (lib.flatten [
46 (lib.getExe self.packages.${pkgs.system}.mycelium)
47 "--key-file ${config.clanCore.secrets.mycelium.secrets.mycelium_key.path}"
48 "--tun-name myc"
49 "--peers" peers
50 ]);
51 Restart = "always";
52 RestartSec = 2;
53 StateDirectory = "mycelium";
54
55 # TODO: Hardening
56 };
57 };
58
59 # TODO get public key from mycelium
60 # TODO get ip from key
61 clanCore.secrets.mycelium = {
62 secrets."mycelium_key" = { };
63 generator = {
64 path = [
65 self.packages.${pkgs.system}.mycelium
66 pkgs.coreutils
67 ];
68 script = ''
69 timeout 5 mycelium --key-file "$secrets"/mycelium_key || :
70 '';
71 };
72 };
73}