2023-03-06 10:13:37 +11:00
|
|
|
{ pkgs
|
|
|
|
, lib ? pkgs.lib
|
|
|
|
, unitDir ? "unit"
|
|
|
|
, packageFun ? "package.nix"
|
|
|
|
, root ? "${./pkgs}/${unitDir}"
|
|
|
|
}:
|
2023-03-06 09:40:35 +11:00
|
|
|
let
|
|
|
|
shards = lib.attrNames (builtins.readDir root);
|
|
|
|
namesForShard = shard: lib.mapAttrs'
|
2023-03-06 12:07:16 +11:00
|
|
|
(name: _: { inherit name; value = root + "/${shard}/${name}"; })
|
|
|
|
(builtins.readDir (root + "/${shard}"));
|
2023-03-06 09:40:35 +11:00
|
|
|
namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards);
|
2023-03-06 12:07:16 +11:00
|
|
|
units = lib.mapAttrs (_: path: pkgs.callPackage (path + "/${packageFun}") { }) namesToPath;
|
2023-03-06 09:40:35 +11:00
|
|
|
in
|
|
|
|
units
|