default: add unit packages (#26)

This commit is contained in:
Alper Çelik
2023-03-06 01:40:35 +03:00
committed by GitHub
parent fc1f1b328b
commit 162045b8d7
3 changed files with 13 additions and 15 deletions

10
callUnitRoot.nix Normal file
View File

@ -0,0 +1,10 @@
{ pkgs, lib ? pkgs.lib, unitDir ? "unit", packageFun ? "package.nix", root ? "${./pkgs}/${unitDir}" }:
let
shards = lib.attrNames (builtins.readDir root);
namesForShard = shard: lib.mapAttrs'
(name: _: { inherit name; value = "${root}/${shard}/${name}"; })
(builtins.readDir "${root}/${shard}");
namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards);
units = lib.mapAttrs (_: path: pkgs.callPackage "${path}/${packageFun}" { }) namesToPath;
in
units