diff options
author | obadz <obadz-git@obadz.com> | 2018-03-27 00:25:53 +0100 |
---|---|---|
committer | obadz <obadz-git@obadz.com> | 2018-03-28 22:18:25 +0100 |
commit | 0a9d7f0809fdf1e0deee703beeb6d758ec3553a5 (patch) | |
tree | 1327f0d895b4da09ba4f6d6e14afee2c46b6683c /nixos | |
parent | decfd44b196796b8f80aa436f1a836d45f20d2f1 (diff) |
zerotier module: add option to join networks and open port
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/networking/zerotierone.nix | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/nixos/modules/services/networking/zerotierone.nix b/nixos/modules/services/networking/zerotierone.nix index 86e0204ec2f72..cd1617b8e2bac 100644 --- a/nixos/modules/services/networking/zerotierone.nix +++ b/nixos/modules/services/networking/zerotierone.nix @@ -7,6 +7,16 @@ let in { options.services.zerotierone.enable = mkEnableOption "ZeroTierOne"; + + options.services.zerotierone.joinNetworks = mkOption { + default = []; + example = [ "a8a2c3c10c1a68de" ]; + type = types.listOf types.str; + description = '' + List of ZeroTier Network IDs to join on startup + ''; + }; + options.services.zerotierone.package = mkOption { default = pkgs.zerotierone; defaultText = "pkgs.zerotierone"; @@ -22,12 +32,13 @@ in path = [ cfg.package ]; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - preStart = - '' - mkdir -p /var/lib/zerotier-one + preStart = '' + mkdir -p /var/lib/zerotier-one/networks.d chmod 700 /var/lib/zerotier-one chown -R root:root /var/lib/zerotier-one - ''; + '' + (concatMapStrings (netId: '' + touch "/var/lib/zerotier-one/networks.d/${netId}.conf" + '') cfg.joinNetworks); serviceConfig = { ExecStart = "${cfg.package}/bin/zerotier-one"; Restart = "always"; @@ -38,6 +49,9 @@ in # ZeroTier does not issue DHCP leases, but some strangers might... networking.dhcpcd.denyInterfaces = [ "zt0" ]; + # ZeroTier receives UDP transmissions on port 9993 by default + networking.firewall.allowedUDPPorts = [ 9993 ]; + environment.systemPackages = [ cfg.package ]; }; } |