From 31d23ba418c16c2c5c81439182ac41dca6fd323d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 9 Feb 2024 05:33:27 +0100 Subject: [PATCH] lib.attrsets: Remove unneeded polyfills Nix 2.3 (the minimum version needed to evaluate Nixpkgs) supports these, so no need to keep them around. --- lib/attrsets.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 0e896a93156d..4f7d795c397f 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -2,10 +2,10 @@ { lib }: let - inherit (builtins) head tail length; - inherit (lib.trivial) id mergeAttrs warn; + inherit (builtins) head length; + inherit (lib.trivial) mergeAttrs warn; inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName; - inherit (lib.lists) foldr foldl' concatMap concatLists elemAt all partition groupBy take foldl; + inherit (lib.lists) foldr foldl' concatMap elemAt all partition groupBy take foldl; in rec { @@ -369,7 +369,7 @@ rec { Type: attrValues :: AttrSet -> [Any] */ - attrValues = builtins.attrValues or (attrs: attrVals (attrNames attrs) attrs); + attrValues = builtins.attrValues; /* Given a set of attribute names, return the set of the corresponding @@ -398,8 +398,7 @@ rec { Type: catAttrs :: String -> [AttrSet] -> [Any] */ - catAttrs = builtins.catAttrs or - (attr: l: concatLists (map (s: if s ? ${attr} then [s.${attr}] else []) l)); + catAttrs = builtins.catAttrs; /* Filter an attribute set by removing all attributes for which the @@ -608,9 +607,7 @@ rec { Type: mapAttrs :: (String -> Any -> Any) -> AttrSet -> AttrSet */ - mapAttrs = builtins.mapAttrs or - (f: set: - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))); + mapAttrs = builtins.mapAttrs; /* Like `mapAttrs`, but allows the name of each attribute to be