mkPackages 2.0

This commit is contained in:
Gerg-L 2023-12-03 21:55:37 -05:00
parent 6cb2c87bbc
commit 36176f647c
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
3 changed files with 39 additions and 7 deletions

View file

@ -105,17 +105,49 @@ rec {
names names
); );
/* /<name> -> packages named by directory
/<name>/call.nix -> callPackage override imported via import <file> pkgs
call.nix example
pkgs: {
inherit (pkgs.python3Packages) callPackage;
args = {};
}
/<name>/package.nix -> the package itself
*/
mkPackages = mkPackages =
path: pkgs: path: pkgs:
lib.pipe path [ lib.pipe path [
listNixFilesRecursive builtins.readDir
(map ( (lib.filterAttrs (_: v: v == "directory"))
x: { (lib.mapAttrs (
name = lib.removeSuffix ".nix" (builtins.baseNameOf x); n: _:
value = pkgs.callPackage x { }; let
addArgs =
x:
lib.setFunctionArgs x (
lib.mapAttrs
(
n: v:
{
inherit inputs self;
#sources = import ../npins;
} }
.${n} or v
)
(lib.functionArgs x)
);
in
if builtins.pathExists "${path}/${n}/call.nix" then
let
x = import "${path}/${n}/call.nix" pkgs;
in
(addArgs x.callPackage "${path}/${n}/package.nix") x.args
else
(addArgs pkgs.callPackage "${path}/${n}/package.nix") {}
)) ))
builtins.listToAttrs
]; ];
_file = ./default.nix; _file = ./default.nix;
} }