From 62b707de07c4aae4a415bc186bda943c70edd3ac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 10 Oct 2012 17:55:13 -0400 Subject: [PATCH] Add support for postStop scripts --- modules/system/boot/systemd-unit-options.nix | 9 +++++++++ modules/system/boot/systemd.nix | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/modules/system/boot/systemd-unit-options.nix b/modules/system/boot/systemd-unit-options.nix index 46f2a705df8..2efea2fb9e1 100644 --- a/modules/system/boot/systemd-unit-options.nix +++ b/modules/system/boot/systemd-unit-options.nix @@ -145,6 +145,15 @@ rec { ''; }; + postStop = mkOption { + type = types.string; + default = ""; + description = '' + Shell commands executed after the service's main process + has exited. + ''; + }; + restartIfChanged = mkOption { type = types.bool; default = true; diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index 268e81b1091..c166c1cbf03 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -250,6 +250,13 @@ let ''} ''} + ${optionalString (def.postStop != "") '' + ExecStopPost=${makeJobScript "${name}-poststop.sh" '' + #! ${pkgs.stdenv.shell} -e + ${def.postStop} + ''} + ''} + ${attrsToSection def.serviceConfig} ''; };