From 4d9dde0edef915c773fd8a1290ec3e3e6abba2e9 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Fri, 28 Feb 2025 13:39:14 +0100 Subject: [PATCH] feat(nix-lib): Add genAttrs' --- lib/nix-lib/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/nix-lib/default.nix b/lib/nix-lib/default.nix index 7afee41..9f635a8 100644 --- a/lib/nix-lib/default.nix +++ b/lib/nix-lib/default.nix @@ -4,18 +4,17 @@ # SPDX-License-Identifier: EUPL-1.2 { lib }: -rec { +let inherit (lib) - flip optionals optionalString - hasPrefix + listToAttrs + nameValuePair recursiveUpdate - splitString - unique - warn ; +in +rec { /* Fuses a list of attribute sets into a single attribute set. @@ -97,6 +96,11 @@ rec { */ mapSingleFuse = f: mapFuse (x: singleAttr x (f x)); + # Like genAttrs but allows configuring the name + genAttrs' = + names: f: g: + listToAttrs (map (n: nameValuePair (f n) (g n)) names); + /* Creates a relative path as a string