From ecb6b54b9e38349ddf6bfbd19b336b6c19cddb34 Mon Sep 17 00:00:00 2001
From: catvayor <catvayor@katvayor.net>
Date: Thu, 6 Feb 2025 10:12:59 +0100
Subject: [PATCH] feat(lib): init genFuse

---
 lib/nix-lib/default.nix | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/nix-lib/default.nix b/lib/nix-lib/default.nix
index 94f8c18..7afee41 100644
--- a/lib/nix-lib/default.nix
+++ b/lib/nix-lib/default.nix
@@ -49,6 +49,24 @@ rec {
     attrsList:
     fuseAttrs (builtins.map f attrsList);
 
+  /*
+    Generate an `attrsList` of given size with the generator before fusing
+    the resulting list of attribute sets.
+
+    Type: (Int -> attrs) -> Int -> attrs
+
+    Example:
+     f = s: { "a${toString s}" = s + s; }
+     genFuse f 3
+     => { a0 = 0; a1 = 2; a2 = 4; }
+  */
+  genFuse =
+    # Int -> attrs
+    f:
+    # Int
+    size:
+    fuseAttrs (builtins.genList f size);
+
   /*
     Equivalent of lib.singleton but for an attribute set.