summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-26 18:24:55 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-26 18:24:55 +0100
commit14cd8bc24874b33e87ec08ddb6d47502e76f17b0 (patch)
tree933c578167bf6c01fa1d1e2529c00410e9766b28 /nixos/modules
parent2b1f21249445991940c9d3ebbc54ce41b1eaf9c0 (diff)
downloadnixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar.gz
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar.bz2
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar.lz
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar.xz
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.tar.zst
nixpkgs-14cd8bc24874b33e87ec08ddb6d47502e76f17b0.zip
Allow services to specify a pre-stop script
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix8
-rw-r--r--nixos/modules/system/boot/systemd.nix6
2 files changed, 14 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 4eb3f1a43a6..c0518599f17 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -210,6 +210,14 @@ in rec {
       '';
     };
 
+    preStop = mkOption {
+      type = types.lines;
+      default = "";
+      description = ''
+        Shell commands executed to stop the service.
+      '';
+    };
+
     postStop = mkOption {
       type = types.lines;
       default = "";
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 31e795ea2d0..51c71c7a5af 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -190,6 +190,12 @@ let
               ${config.postStart}
             '';
           })
+        (mkIf (config.preStop != "")
+          { serviceConfig.ExecStop = makeJobScript "${name}-pre-stop" ''
+              #! ${pkgs.stdenv.shell} -e
+              ${config.preStop}
+            '';
+          })
         (mkIf (config.postStop != "")
           { serviceConfig.ExecStopPost = makeJobScript "${name}-post-stop" ''
               #! ${pkgs.stdenv.shell} -e