mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
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.
This commit is contained in:
parent
03d9bbcfa9
commit
b415876bdb
1 changed files with 6 additions and 4 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue