From fc513d020b35545da312241125fa5cb60b3d4a0f Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Fri, 30 Jan 2026 17:32:55 +0100 Subject: [PATCH] nixos/systemd-lib: use structuredAttrs instead of passAsFile for makeUnit --- nixos/lib/systemd-lib.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix index 8397eca39c51..9f5ec37e5270 100644 --- a/nixos/lib/systemd-lib.nix +++ b/nixos/lib/systemd-lib.nix @@ -76,16 +76,13 @@ rec { { preferLocalBuild = true; allowSubstitutes = false; - # 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" ]; + text = unit.text or ""; + __structuredAttrs = true; } '' name=${shellEscape name} mkdir -p "$out/$(dirname -- "$name")" - mv "$textPath" "$out/$name" + printf "%s" "$text" > "$out/$name" '' else pkgs.runCommand "unit-${mkPathSafeName name}-disabled"