From 13d747c11a6935272a2ebdb861daefbdfde47d15 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 1 Oct 2012 16:45:49 -0400 Subject: [PATCH] Support postStart scripts in service units --- 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 c5fa23b36bb0..95506712caca 100644 --- a/modules/system/boot/systemd-unit-options.nix +++ b/modules/system/boot/systemd-unit-options.nix @@ -122,6 +122,15 @@ with pkgs.lib; ''; }; + postStart = mkOption { + type = types.string; + default = ""; + description = '' + Shell commands executed after the service's main process + is started. + ''; + }; + restartIfChanged = mkOption { type = types.bool; default = true; diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index a7a7729bb8b9..bb2ea087c21c 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -229,6 +229,13 @@ let ''} ''} + ${optionalString (def.postStart != "") '' + ExecStartPost=${makeJobScript "${name}-poststart.sh" '' + #! ${pkgs.stdenv.shell} -e + ${def.postStart} + ''} + ''} + ${attrsToSection def.serviceConfig} ''; };