about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorKirill Elagin <kirelagin@gmail.com>2020-04-17 10:12:34 +0300
committerKirill Elagin <kirelagin@gmail.com>2020-04-17 10:17:46 +0300
commit5822d03851cfd9e8e7449c05c2cea2232e52cc42 (patch)
treee7a5a4150a38ca6d081ae62899aebe6bf196d836 /nixos/modules/system
parent1d20b2872ffac15ed363cef822ba72428a98b220 (diff)
downloadnixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar.gz
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar.bz2
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar.lz
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar.xz
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.tar.zst
nixlib-5822d03851cfd9e8e7449c05c2cea2232e52cc42.zip
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.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/systemd.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 7f207e6c7ef4..7682b26e5b7f 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 = {