nixos/systemd-lib: fix building of empty unit files
This is a fixup for c1ae82f448
.
nix' `passAsFile` does not create empty files for variables that are
`null`.
This results in the following error for units that have no overrides or
content, but are, e.g. `wantedBy`:
`mv: cannot stat '': No such file or directory`.
Minimal reproducer:
`systemd.units.empty.wantedBy = [ "multi-user.target" ];`
This is often necessary when a unit is loaded in via `systemd.packages`.
This commit is contained in:
parent
90b0f71e5d
commit
6c7ad5e732
1 changed files with 4 additions and 1 deletions
|
@ -20,7 +20,10 @@ in rec {
|
|||
pkgs.runCommand "unit-${mkPathSafeName name}"
|
||||
{ preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
inherit (unit) text;
|
||||
# unit.text can be null. But variables that are null listed in
|
||||
# passAsFile are ignored by nix, resulting in no file being created,
|
||||
# making the mv operation fail.
|
||||
text = optionalString (unit.text != null) unit.text;
|
||||
passAsFile = [ "text" ];
|
||||
}
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue