summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-17 15:02:53 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-17 15:02:53 +0100
commit511b86d22dbf3d4a52ac9d6437f0ee0375468f01 (patch)
tree1c8bdb098eaa4cf95cb3cc3c44114b3940b31797
parent28b7d67d08a7a76c7508d4b6a8f791c2eba4a1b9 (diff)
downloadnixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.gz
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.bz2
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.lz
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.xz
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.zst
nixpkgs-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.zip
Add an option to reload rather than restart changed units
-rw-r--r--nixos/modules/system/activation/switch-to-configuration.pl5
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix11
-rw-r--r--nixos/modules/system/boot/systemd.nix6
3 files changed, 20 insertions, 2 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl
index 67b2280af3b..fd2b5b7950d 100644
--- a/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixos/modules/system/activation/switch-to-configuration.pl
@@ -176,7 +176,10 @@ while (my ($unit, $state) = each %{$activePrev}) {
                 # FIXME: do something?
             } else {
                 my $unitInfo = parseUnit($newUnitFile);
-                if (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes")) {
+                if (boolIsTrue($unitInfo->{'X-ReloadIfChanged'} // "no")) {
+                    write_file($reloadListFile, { append => 1 }, "$unit\n");
+                }
+                elsif (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes")) {
                     push @unitsToSkip, $unit;
                 } else {
                     # If this unit is socket-activated, then stop the
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 113990814ef..784025f6bab 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -243,6 +243,17 @@ in rec {
       '';
     };
 
+    reloadIfChanged = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Whether the service should be reloaded during a NixOS
+        configuration switch if its definition has changed.  If
+        enabled, the value of <option>restartIfChanged</option> is
+        ignored.
+      '';
+    };
+
     stopIfChanged = mkOption {
       type = types.bool;
       default = true;
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 49502b3e685..b31c631a0a7 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -279,7 +279,11 @@ let
           [Service]
           ${let env = cfg.globalEnvironment // def.environment;
             in concatMapStrings (n: "Environment=\"${n}=${getAttr n env}\"\n") (attrNames env)}
-          ${optionalString (!def.restartIfChanged) "X-RestartIfChanged=false"}
+          ${if def.reloadIfChanged then ''
+            X-ReloadIfChanged=true
+          '' else if !def.restartIfChanged then ''
+            X-RestartIfChanged=false
+          '' else ""}
           ${optionalString (!def.stopIfChanged) "X-StopIfChanged=false"}
           ${attrsToSection def.serviceConfig}
         '';