lib/generators: explicitly import names from lib.attrsets

Everything used was already imported.
This commit is contained in:
Philip Taron 2024-03-06 16:22:49 -08:00
parent 9513152413
commit b83b8a3548
No known key found for this signature in database

View file

@ -16,8 +16,6 @@
{ lib }: { lib }:
with (lib).trivial; with (lib).trivial;
let let
libAttr = lib.attrsets;
inherit (builtins) inherit (builtins)
addErrorContext addErrorContext
attrNames attrNames
@ -143,7 +141,7 @@ rec {
mkLines = if listsAsDuplicateKeys mkLines = if listsAsDuplicateKeys
then k: v: map (mkLine k) (if isList v then v else [v]) then k: v: map (mkLine k) (if isList v then v else [v])
else k: v: [ (mkLine k v) ]; else k: v: [ (mkLine k v) ];
in attrs: concatStrings (concatLists (libAttr.mapAttrsToList mkLines attrs)); in attrs: concatStrings (concatLists (mapAttrsToList mkLines attrs));
/* Generate an INI-style config file from an /* Generate an INI-style config file from an
@ -178,7 +176,7 @@ rec {
# map function to string for each key val # map function to string for each key val
mapAttrsToStringsSep = sep: mapFn: attrs: mapAttrsToStringsSep = sep: mapFn: attrs:
concatStringsSep sep concatStringsSep sep
(libAttr.mapAttrsToList mapFn attrs); (mapAttrsToList mapFn attrs);
mkSection = sectName: sectValues: '' mkSection = sectName: sectValues: ''
[${mkSectionName sectName}] [${mkSectionName sectName}]
'' + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues; '' + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues;
@ -399,7 +397,7 @@ rec {
+ outroSpace + "]" + outroSpace + "]"
else if isFunction v then else if isFunction v then
let fna = functionArgs v; let fna = functionArgs v;
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList showFnas = concatStringsSep ", " (mapAttrsToList
(name: hasDefVal: if hasDefVal then name + "?" else name) (name: hasDefVal: if hasDefVal then name + "?" else name)
fna); fna);
in if fna == {} then "<function>" in if fna == {} then "<function>"
@ -412,7 +410,7 @@ rec {
else if v ? type && v.type == "derivation" then else if v ? type && v.type == "derivation" then
"<derivation ${v.name or "???"}>" "<derivation ${v.name or "???"}>"
else "{" + introSpace else "{" + introSpace
+ concatStringsSep introSpace (libAttr.mapAttrsToList + concatStringsSep introSpace (mapAttrsToList
(name: value: (name: value:
"${escapeNixIdentifier name} = ${ "${escapeNixIdentifier name} = ${
addErrorContext "while evaluating an attribute `${name}`" addErrorContext "while evaluating an attribute `${name}`"
@ -574,7 +572,7 @@ ${expr "" v}
"(${v.expr})" "(${v.expr})"
else if v == { } then else if v == { } then
"{}" "{}"
else if libAttr.isDerivation v then else if isDerivation v then
''"${toString v}"'' ''"${toString v}"''
else else
"{${introSpace}${concatItems ( "{${introSpace}${concatItems (