nixos/lib: Support derivations in escapeSystemdExecArg

They can be transformed into their outpath string, which is useful for
config generators.
This commit is contained in:
Martin Weinelt 2024-03-23 15:59:50 +01:00
parent 4f08de1c5c
commit a4b6e457b8
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
1 changed files with 2 additions and 2 deletions

View File

@ -64,8 +64,8 @@ rec {
let
s = if builtins.isPath arg then "${arg}"
else if builtins.isString arg then arg
else if builtins.isInt arg || builtins.isFloat arg then toString arg
else throw "escapeSystemdExecArg only allows strings, paths and numbers";
else if builtins.isInt arg || builtins.isFloat arg || lib.isDerivation arg then toString arg
else throw "escapeSystemdExecArg only allows strings, paths, numbers and derivations";
in
replaceStrings [ "%" "$" ] [ "%%" "$$" ] (builtins.toJSON s);