diff options
author | Yonghan Ching 庄勇翰 <yonghan@y525.net> | 2023-12-17 17:29:14 -0600 |
---|---|---|
committer | Emery Hemingway <ehmry@posteo.net> | 2023-12-19 12:34:03 +0000 |
commit | 097f2b673741570eaf0d475127b3f5c6edbd2f0f (patch) | |
tree | 8c570e3cefae3c83ffd71370c3406b866e1354f1 /nixos | |
parent | 9a9873567d51678ed013cf0698a58ac3d7570f93 (diff) |
Update zerotierone.nix
Added option to write zerotier's local.conf in nix.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/networking/zerotierone.nix | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/zerotierone.nix b/nixos/modules/services/networking/zerotierone.nix index 994e01d4980ea..e4e17cb1ded88 100644 --- a/nixos/modules/services/networking/zerotierone.nix +++ b/nixos/modules/services/networking/zerotierone.nix @@ -28,7 +28,20 @@ in }; options.services.zerotierone.package = mkPackageOption pkgs "zerotierone" { }; - + + options.services.zerotierone.localConf = mkOption { + default = { }; + description = mdDoc '' + Configuration to be written to the zerotier JSON-based local.conf. + The configuration will be symlinked to /var/lib/zerotier-one/local.conf at build time. + To understand the configuration format, refer to https://docs.zerotier.com/config/#local-configuration-options. + ''; + example = { + settings.allowTcpFallbackRelay = false; + }; + type = types.attrs; + }; + config = mkIf cfg.enable { systemd.services.zerotierone = { description = "ZeroTierOne"; @@ -45,7 +58,9 @@ in chown -R root:root /var/lib/zerotier-one '' + (concatMapStrings (netId: '' touch "/var/lib/zerotier-one/networks.d/${netId}.conf" - '') cfg.joinNetworks); + '') cfg.joinNetworks) + '' + ln -s ${conf} /var/lib/zerotier-one/local.conf + ''; serviceConfig = { ExecStart = "${cfg.package}/bin/zerotier-one -p${toString cfg.port}"; Restart = "always"; |