From 02c3f8ed7b878d4cdce9a90e8e4fb4acd3543613 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Sun, 7 Jun 2026 08:31:28 -0400 Subject: [PATCH] pkgs.formats.keyValue: do more logic before generation Allows more caching if the same generator is called multiple times. --- pkgs/pkgs-lib/formats.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix index 3576a00e9943..e81cec4212b0 100644 --- a/pkgs/pkgs-lib/formats.nix +++ b/pkgs/pkgs-lib/formats.nix @@ -449,15 +449,15 @@ optionalAttrs allowAliases aliases attrsOf atom; generate = - name: value: let - transformedValue = + transformValue = if listToValue != null then - mapAttrs (key: val: if isList val then listToValue val else val) value + mapAttrs (key: val: if isList val then listToValue val else val) else - value; + id; + finalArgs = removeAttrs args [ "listToValue" ]; in - pkgs.writeText name (toKeyValue (removeAttrs args [ "listToValue" ]) transformedValue); + name: value: pkgs.writeText name (toKeyValue finalArgs (transformValue value)); };