Use packagesFromDirectoryRecursive to improve package building

This commit is contained in:
ulic-youthlic 2025-07-12 23:57:53 +08:00
parent 57dafbe7e1
commit 8aa578123c
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
10 changed files with 27 additions and 33 deletions

View file

@ -14,7 +14,6 @@
...
}: let
inherit (inputs) nixpkgs;
callPackages = lib.callPackagesWith (pkgs // {inherit callPackages inputs rootPath lib;});
in {
_module.args.pkgs = import nixpkgs {
inherit system;
@ -33,7 +32,31 @@
nvfetcher
];
};
packages = callPackages (rootPath + "/pkgs") {};
checks = self'.packages;
legacyPackages = let
inputsScope = lib.makeScope pkgs.newScope (self: {
inherit inputs rootPath;
srcs = self.callPackage (rootPath + "/_sources/generated.nix") {};
});
in
lib.packagesFromDirectoryRecursive {
inherit (inputsScope) callPackage;
directory = rootPath + "/pkgs";
};
packages = let
flattenPkgs = path: value:
if lib.isDerivation value
then {
${lib.concatStringsSep "/" path} = value;
}
else if lib.isAttrs value
then lib.concatMapAttrs (name: flattenPkgs (path ++ [name])) value
else {};
in
flattenPkgs [] self'.legacyPackages;
checks =
lib.concatMapAttrs (name: value: {
"package-${name}" = value;
})
self'.packages;
};
}