diff options
author | Kirill Elagin <kirelagin@gmail.com> | 2020-04-17 13:55:48 +0300 |
---|---|---|
committer | Kirill Elagin <kirelagin@gmail.com> | 2020-04-17 13:55:48 +0300 |
commit | a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83 (patch) | |
tree | a7788e4f4f9037df3113e29db3c1221bd0ecf7a8 /nixos/modules/system | |
parent | f1a78e1b5ea83d4875490d823e2ea5903edd282b (diff) | |
download | nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar.gz nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar.bz2 nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar.lz nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar.xz nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.tar.zst nixpkgs-a9e9d37fc8b7df73d68f9ed78f25da15a40a1c83.zip |
systemd: Add prefix to unit script derivations
Add a distinctive `unit-script` prefix to systemd unit scripts to make them easier to find in the store directory. Do not add this prefix to actual script file name as it clutters logs.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/systemd.nix | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index caa3435cfcd..516f8ed7541 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -203,10 +203,20 @@ let makeJobScript = name: text: let scriptName = replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape name); - out = pkgs.writeShellScriptBin scriptName '' - set -e - ${text} - ''; + out = pkgs.writeTextFile { + # The derivation name is different from the script file name + # to keep the script file name short to avoid cluttering logs. + name = "unit-script-${scriptName}"; + executable = true; + destination = "/bin/${scriptName}"; + text = '' + #!${pkgs.runtimeShell} -e + ${text} + ''; + checkPhase = '' + ${pkgs.stdenv.shell} -n "$out/bin/${scriptName}" + ''; + }; in "${out}/bin/${scriptName}"; unitConfig = { config, options, ... }: { |