From 4e59b77c7099f6459619d11131855010c555e5de Mon Sep 17 00:00:00 2001 From: nicoo Date: Mon, 16 Sep 2024 21:42:39 +0000 Subject: [PATCH] lib.fetchers: factor-out definitions common to `normalizeHash` and `withNormalizedHash` --- lib/fetchers.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/fetchers.nix b/lib/fetchers.nix index ed2340b80322..07ed09669c7c 100644 --- a/lib/fetchers.nix +++ b/lib/fetchers.nix @@ -1,6 +1,11 @@ # snippets that can be shared by multiple fetchers (pkgs/build-support) { lib }: -rec { +let + commonH = hashTypes: rec { + hNames = [ "hash" ] ++ hashTypes; + hAttrs = lib.genAttrs hNames (lib.const {}); + }; +in rec { proxyImpureEnvVars = [ # We borrow these environment variables from the caller to allow @@ -68,11 +73,10 @@ rec { required ? true, }: let - inherit (lib) concatMapStringsSep const head tail throwIf; - inherit (lib.attrsets) attrsToList genAttrs intersectAttrs removeAttrs optionalAttrs; + inherit (lib) concatMapStringsSep head tail throwIf; + inherit (lib.attrsets) attrsToList intersectAttrs removeAttrs optionalAttrs; - hNames = [ "hash" ] ++ hashTypes; - hAttrs = genAttrs hNames (const {}); + inherit (commonH hashTypes) hAttrs hNames; in args: if args ? "outputHash" then @@ -153,7 +157,7 @@ rec { inherit (lib.attrsets) genAttrs intersectAttrs removeAttrs; inherit (lib.trivial) const functionArgs setFunctionArgs; - hAttrs = genAttrs ([ "hash" ] ++ hashTypes) (const {}); + inherit (commonH hashTypes) hAttrs; fArgs = functionArgs fetcher; normalize = normalizeHash {