summary refs log tree commit diff
diff options
context:
space:
mode:
authorTavi <syncopegirl@gmail.com>2022-12-19 16:39:52 -0500
committerTavi <syncopegirl@gmail.com>2022-12-19 20:35:00 -0500
commitca591e700875b8439557cdc02a271014c35fcd0e (patch)
tree5a4cf38c5a57c7c6fb0348d3747d46d3bb6c9070
parent81f1863ca7cc4d2963115ffa96dae6531f8b0aa6 (diff)
downloadnixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar.gz
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar.bz2
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar.lz
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar.xz
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.tar.zst
nixpkgs-ca591e700875b8439557cdc02a271014c35fcd0e.zip
nixos/services.tinc: Add all generated /etc/ files to reloadTriggers
Bug fix for issue #66431. Adds all files created as a result of
hostSettings configuration to the created service's reloadTriggers,
or to restartTriggers if the version of tinc isn't 1.1pre or later.
-rw-r--r--nixos/modules/services/networking/tinc.nix17
1 files changed, 10 insertions, 7 deletions
diff --git a/nixos/modules/services/networking/tinc.nix b/nixos/modules/services/networking/tinc.nix
index 09b23a60a4a..471e4d34cd6 100644
--- a/nixos/modules/services/networking/tinc.nix
+++ b/nixos/modules/services/networking/tinc.nix
@@ -349,9 +349,9 @@ in
 
   ###### implementation
 
-  config = mkIf (cfg.networks != { }) {
-
-    environment.etc = foldr (a: b: a // b) { }
+  config = mkIf (cfg.networks != { }) (
+    let
+    etcConfig = foldr (a: b: a // b) { }
       (flip mapAttrsToList cfg.networks (network: data:
         flip mapAttrs' data.hosts (host: text: nameValuePair
           ("tinc/${network}/hosts/${host}")
@@ -366,19 +366,22 @@ in
           };
         }
       ));
+    in {
+    environment.etc = etcConfig;
 
     systemd.services = flip mapAttrs' cfg.networks (network: data: nameValuePair
       ("tinc.${network}")
-      ({
+      (let version = getVersion data.package; in {
         description = "Tinc Daemon - ${network}";
         wantedBy = [ "multi-user.target" ];
         path = [ data.package ];
-        restartTriggers = [ config.environment.etc."tinc/${network}/tinc.conf".source ];
+        reloadTriggers = mkIf (versionAtLeast version "1.1pre") [ (builtins.toJSON etcConfig) ];
+        restartTriggers = mkIf (versionOlder version "1.1pre") [ (builtins.toJSON etcConfig) ];
         serviceConfig = {
           Type = "simple";
           Restart = "always";
           RestartSec = "3";
-          ExecReload = mkIf (versionAtLeast (getVersion data.package) "1.1pre") "${data.package}/bin/tinc -n ${network} reload";
+          ExecReload = mkIf (versionAtLeast version "1.1pre") "${data.package}/bin/tinc -n ${network} reload";
           ExecStart = "${data.package}/bin/tincd -D -U tinc.${network} -n ${network} ${optionalString (data.chroot) "-R"} --pidfile /run/tinc.${network}.pid -d ${toString data.debugLevel}";
         };
         preStart = ''
@@ -433,7 +436,7 @@ in
     users.groups = flip mapAttrs' cfg.networks (network: _:
       nameValuePair "tinc.${network}" {}
     );
-  };
+  });
 
   meta.maintainers = with maintainers; [ minijackson mic92 ];
 }