10 cfg = config.services.mycelium;
13 options.services.mycelium = {
14 enable = lib.mkEnableOption "mycelium network";
15 peers = lib.mkOption {
16 type = lib.types.listOf lib.types.str;
18 List of peers to connect to, in the formats:
19 - `quic://[2001:0db8::1]:9651`
20 - `quic://192.0.2.1:9651`
21 - `tcp://[2001:0db8::1]:9651`
22 - `tcp://192.0.2.1:9651`
24 If addHostedPublicNodes is set to true, the hosted public nodes will also be added.
28 keyFile = lib.mkOption {
29 type = lib.types.nullOr lib.types.path;
32 Optional path to a file containing the mycelium key material.
33 If unset, the default location (`/var/lib/mycelium/key.bin`) will be used.
34 If no key exist at this location, it will be generated on startup.
37 openFirewall = lib.mkOption {
38 type = lib.types.bool;
40 description = "Open the firewall for mycelium";
42 package = lib.mkOption {
43 type = lib.types.package;
44 default = pkgs.mycelium;
45 defaultText = lib.literalExpression ''"''${pkgs.mycelium}"'';
46 description = "The mycelium package to use";
48 addHostedPublicNodes = lib.mkOption {
49 type = lib.types.bool;
52 Adds the hosted peers from https://github.com/threefoldtech/mycelium#hosted-public-nodes.
55 extraArgs = lib.mkOption {
56 type = lib.types.listOf lib.types.str;
59 Extra command-line arguments to pass to mycelium.
61 See `mycelium --help` for all available options.
65 config = lib.mkIf cfg.enable {
66 networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ 9651 ];
67 networking.firewall.allowedUDPPorts = lib.optionals cfg.openFirewall [
72 environment.systemPackages = [ cfg.package ];
74 systemd.services.mycelium = {
75 description = "Mycelium network";
76 after = [ "network.target" ];
77 wantedBy = [ "multi-user.target" ];
82 unitConfig.Documentation = "https://github.com/threefoldtech/mycelium";
87 StateDirectory = "mycelium";
90 LoadCredential = lib.mkIf (cfg.keyFile != null) "keyfile:${cfg.keyFile}";
91 SyslogIdentifier = "mycelium";
92 AmbientCapabilities = [ "CAP_NET_ADMIN" ];
93 MemoryDenyWriteExecute = true;
94 ProtectControlGroups = true;
95 ProtectKernelModules = true;
96 ProtectKernelTunables = true;
97 RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
98 RestrictNamespaces = true;
99 RestrictRealtime = true;
100 SystemCallArchitectures = "native";
103 "~@privileged @keyring"
105 ExecStart = lib.concatStringsSep " " (
107 (lib.getExe cfg.package)
109 if (cfg.keyFile != null) then
110 "--key-file \${CREDENTIALS_DIRECTORY}/keyfile"
112 "--key-file %S/mycelium/key.bin"
116 "${utils.escapeSystemdExecArgs cfg.extraArgs}"
118 ++ (lib.optional (cfg.addHostedPublicNodes || cfg.peers != [ ]) "--peers")
120 ++ (lib.optionals cfg.addHostedPublicNodes [
121 "tcp://188.40.132.242:9651" # DE 01
122 "tcp://[2a01:4f8:221:1e0b::2]:9651"
123 "quic://188.40.132.242:9651"
124 "quic://[2a01:4f8:221:1e0b::2]:9651"
126 "tcp://136.243.47.186:9651" # DE 02
127 "tcp://[2a01:4f8:212:fa6::2]:9651"
128 "quic://136.243.47.186:9651"
129 "quic://[2a01:4f8:212:fa6::2]:9651"
131 "tcp://185.69.166.7:9651" # BE 03
132 "tcp://[2a02:1802:5e:0:8478:51ff:fee2:3331]:9651"
133 "quic://185.69.166.7:9651"
134 "quic://[2a02:1802:5e:0:8478:51ff:fee2:3331]:9651"
136 "tcp://185.69.166.8:9651" # BE 04
137 "tcp://[2a02:1802:5e:0:8c9e:7dff:fec9:f0d2]:9651"
138 "quic://185.69.166.8:9651"
139 "quic://[2a02:1802:5e:0:8c9e:7dff:fec9:f0d2]:9651"
141 "tcp://65.21.231.58:9651" # FI 05
142 "tcp://[2a01:4f9:6a:1dc5::2]:9651"
143 "quic://65.21.231.58:9651"
144 "quic://[2a01:4f9:6a:1dc5::2]:9651"
146 "tcp://65.109.18.113:9651" # FI 06
147 "tcp://[2a01:4f9:5a:1042::2]:9651"
148 "quic://65.109.18.113:9651"
149 "quic://[2a01:4f9:5a:1042::2]:9651"
159 maintainers = with lib.maintainers; [