diff --git a/modules/system/boot/systemd-unit-options.nix b/modules/system/boot/systemd-unit-options.nix index c5fa23b36bb..95506712cac 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 a7a7729bb8b..bb2ea087c21 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} ''; };