summary refs log tree commit diff
path: root/nixos/modules
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 /nixos/modules
parent28b7d67d08a7a76c7508d4b6a8f791c2eba4a1b9 (diff)
downloadnixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.gz
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.bz2
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.lz
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.xz
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.tar.zst
nixlib-511b86d22dbf3d4a52ac9d6437f0ee0375468f01.zip
Add an option to reload rather than restart changed units
Diffstat (limited to 'nixos/modules')
-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 67b2280af3be..fd2b5b7950d5 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 113990814efa..784025f6bab2 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 49502b3e6851..b31c631a0a7b 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}
         '';