about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorYonghan Ching 庄勇翰 <yonghan@y525.net>2023-12-17 19:21:01 -0600
committerEmery Hemingway <ehmry@posteo.net>2023-12-19 12:34:03 +0000
commitb233faab8289d208a0398d19cc08fd53db5efec8 (patch)
treed70c850ab5aa882952cfaafe26c892f31d8851a5 /nixos
parent36791bab6a507e440f433c6238318b612a4c8556 (diff)
Update zerotierone.nix
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/zerotierone.nix8
1 files changed, 7 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/zerotierone.nix b/nixos/modules/services/networking/zerotierone.nix
index 79de68e8c45e7..20cd9c87e2ed2 100644
--- a/nixos/modules/services/networking/zerotierone.nix
+++ b/nixos/modules/services/networking/zerotierone.nix
@@ -4,6 +4,8 @@ with lib;
 
 let
   cfg = config.services.zerotierone;
+  conf = pkgs.writeText "zt-local.conf" (builtins.toJSON cfg.localConf);
+  localConfFilePath = "/var/lib/zerotier-one/local.conf";
 in
 {
   options.services.zerotierone.enable = mkEnableOption (lib.mdDoc "ZeroTierOne");
@@ -59,7 +61,11 @@ in
       '' + (concatMapStrings (netId: ''
         touch "/var/lib/zerotier-one/networks.d/${netId}.conf"
       '') cfg.joinNetworks) + ''
-        ln -s ${conf} /var/lib/zerotier-one/local.conf
+        if [ -e "${localConfFilePath}" ]
+        then
+          rm ${localConfFilePath}
+        fi
+        ln -s ${conf} ${localConfFilePath}
       '';
 
       serviceConfig = {