servers/lib/packages.nix

26 lines
632 B
Nix
Raw Normal View History

2026-02-24 00:00:35 -08:00
pkgs:
let
getPackages =
dir:
let
entries = builtins.readDir dir;
2025-01-26 18:49:45 -06:00
2026-02-24 00:00:35 -08:00
procEntry =
name: type:
let
path = dir + "/${name}";
in
if type == "directory" then
(if builtins.pathExists (path + "/default.nix") then [ path ] else [ ])
else
[ ];
2025-01-26 18:49:45 -06:00
in
2026-02-24 00:00:35 -08:00
builtins.concatLists (builtins.attrValues (builtins.mapAttrs procEntry entries));
2025-01-26 18:49:45 -06:00
buildPackage = path: {
name = builtins.baseNameOf (toString path);
2026-02-24 00:00:35 -08:00
value = pkgs.callPackage (path + "/default.nix") { };
2025-01-26 18:49:45 -06:00
};
in
2026-02-24 00:00:35 -08:00
builtins.listToAttrs (builtins.map buildPackage (getPackages ../packages))