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

@ -16,7 +16,7 @@ update:
nix flake update --log-format internal-json 2>&1 | nom --json
updatePkgs:
cd pkgs && nvfetcher
nvfetcher
build specialisation=DEFAULT_SPECIALISATION:
nh os build {{ FLAKE_HOME }} {{ if specialisation == DEFAULT_SPECIALISATION { "-S" } else { "-s " + specialisation } }}

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;
};
}

View file

@ -1,29 +0,0 @@
{
inputs,
rootPath,
callPackages,
lib,
pkgs,
...
}: let
srcs = callPackages ./_sources/generated.nix {};
callPackage = lib.callPackageWith (pkgs // {inherit inputs srcs callPackage rootPath;});
in {
pinentry-selector = callPackage ./pinentry-selector.nix {};
helix = callPackage ./helix {};
juicity = callPackage ./juicity.nix {};
spotifyx = callPackage ./spotifyx.nix {};
radicle-explorer = callPackage ./radicle-explorer.nix {};
TrackersListCollection = callPackage ./TrackersListCollection.nix {};
wshowkeys-mao = callPackage ./wshowkeys-mao.nix {};
OuterWildsTextAdventure = callPackage ./OuterWildsTextAdventure.nix {};
QQ = callPackage ./QQ.nix {};
editor-runtime = callPackage ./editor-runtime.nix {};
cliphist = callPackage ./cliphist.nix {};
radicle-ci-broker = callPackage ./radicle-ci-broker.nix {};
rime-yuhaostar = callPackage ./rime-yuhaostar {};
noto-serif-cjk = callPackage ./noto-serif-cjk.nix {};
noto-sans-cjk = callPackage ./noto-sans-cjk.nix {};
wallpapers = callPackage ./wallpapers.nix {};
}