diff options
author | Evgeny Egorochkin <phreedom@yandex.ru> | 2014-06-09 22:41:07 +0300 |
---|---|---|
committer | Evgeny Egorochkin <phreedom@yandex.ru> | 2014-06-11 04:08:13 +0300 |
commit | b415876bdbb257f1281a5092e8f56dee7878fe05 (patch) | |
tree | 5510e0293d452946d294e7e9fb1709013e7592ac /nixos/modules/system | |
parent | 03d9bbcfa993c915b359b6fff66add2b3dc0288d (diff) | |
download | nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar.gz nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar.bz2 nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar.lz nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar.xz nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.tar.zst nixlib-b415876bdbb257f1281a5092e8f56dee7878fe05.zip |
systemd service: fix issues with escaping when unit name contains '-'
systemd escaping rules translate this into a string containing '\' which is treated by some code paths as quoted, and by others as unquoted causing the affected units to fail.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/systemd.nix | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 761600f9e551..ee94c91716cf 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -15,13 +15,13 @@ let pkgs.runCommand "unit" { preferLocalBuild = true; inherit (unit) text; } '' mkdir -p $out - echo -n "$text" > $out/${name} + echo -n "$text" > $out/${shellEscape name} '' else pkgs.runCommand "unit" { preferLocalBuild = true; } '' mkdir -p $out - ln -s /dev/null $out/${name} + ln -s /dev/null $out/${shellEscape name} ''; upstreamSystemUnits = @@ -187,9 +187,11 @@ let "timers.target" ]; + shellEscape = s: (replaceChars [ "\\" ] [ "\\\\" ] s); + makeJobScript = name: text: - let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${name}"; inherit text; }; - in "${x}/bin/${name}"; + let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${shellEscape name}"; inherit text; }; + in "${x}/bin/${shellEscape name}"; unitConfig = { name, config, ... }: { config = { |