From 5822d03851cfd9e8e7449c05c2cea2232e52cc42 Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Fri, 17 Apr 2020 10:12:34 +0300 Subject: [PATCH] systemd: Simplify unit script names Current journal output from services started by `script` rather than `ExexStart` is unreadable because the name of the file (which journalctl records and outputs) quite literally takes 1/3 of the screen (on smaller screens). Make it shorter. In particular: * Drop the `unit-script` prefix as it is not very useful. * Use `writeShellScriptBin` to write them because: * It has a `checkPhase` which is better than no checkPhase. * The script itself ends up having a short name. --- nixos/modules/system/boot/systemd.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 7f207e6c7ef..7682b26e5b7 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -201,8 +201,13 @@ let ]; makeJobScript = name: text: - let mkScriptName = s: "unit-script-" + (replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape s) ); - in pkgs.writeTextFile { name = mkScriptName name; executable = true; inherit text; }; + let + scriptName = replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape name); + out = pkgs.writeShellScriptBin scriptName '' + set -e + ${text} + ''; + in "${out}/bin/${scriptName}"; unitConfig = { config, options, ... }: { config = {