Unverified Commit 9f180c54 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

Merge pull request #280517 from Mic92/zerotierone

nixos/zerotierone: make localConf mergeable
parents c80fa315 09ead1f6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -4,7 +4,9 @@ with lib;

let
  cfg = config.services.zerotierone;
  localConfFile = pkgs.writeText "zt-local.conf" (builtins.toJSON cfg.localConf);

  settingsFormat = pkgs.formats.json {};
  localConfFile = settingsFormat.generate "zt-local.conf" cfg.localConf;
  localConfFilePath = "/var/lib/zerotier-one/local.conf";
in
{
@@ -41,7 +43,7 @@ in
    example = {
      settings.allowTcpFallbackRelay = false;
    };
    type = types.nullOr types.attrs;
    type = settingsFormat.type;
  };

  config = mkIf cfg.enable {
@@ -60,7 +62,7 @@ in
        chown -R root:root /var/lib/zerotier-one
      '' + (concatMapStrings (netId: ''
        touch "/var/lib/zerotier-one/networks.d/${netId}.conf"
      '') cfg.joinNetworks) + optionalString (cfg.localConf != null) ''
      '') cfg.joinNetworks) + optionalString (cfg.localConf != {}) ''
        if [ -L "${localConfFilePath}" ]
        then
          rm ${localConfFilePath}