lib.generators.toGitINI: don't traverse derivations

Consider a derivation a value to be serialized.

    nix-repl> lib.generators.toGitINI { hello = { drv = pkgs.hello; }; }
    error: evaluation aborted with the following error message: 'generators.mkValueStringDefault: attrsets not supported: <derivation /nix/store/533q15q67sl6dl0272dyi7m7w5pwkkjh-hello-2.10.drv>'

Fixes #137390
This commit is contained in:
zimbatm 2021-09-12 06:19:25 +02:00
parent fc4247e827
commit 9e90a400a5
No known key found for this signature in database
GPG Key ID: 71BAF6D40C1D63D7

View File

@ -169,7 +169,7 @@ rec {
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
gitFlattenAttrs = let gitFlattenAttrs = let
recurse = path: value: recurse = path: value:
if isAttrs value then if isAttrs value && !lib.isDerivation value then
lib.mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value lib.mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
else if length path > 1 then { else if length path > 1 then {
${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value; ${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value;