1
1
forked from extern/flakelight

Make output packages available in all pkgs parameters

This enables using packages defined by the flake from the pkgs input of apps,
for example.
This commit is contained in:
Archit Gupta 2023-04-13 19:19:58 -07:00
parent 4ec111408e
commit dab3eb948d

View File

@ -111,23 +111,21 @@ let
((map (m: normalizeModule (m src inputs root')) ((map (m: normalizeModule (m src inputs root'))
([ baseModule ] ++ modules)) ++ [ root' ]); ([ baseModule ] ++ modules)) ++ [ root' ]);
genPackages = pkgs: mapAttrs (_: v: pkgs.callPackage v { });
pkgsFor = system: import (inputs.nixpkgs or nixpkgs) { pkgsFor = system: import (inputs.nixpkgs or nixpkgs) {
inherit system; inherit system;
overlays = merged.withOverlays; overlays = merged.withOverlays ++ [
(final: _: genPackages final merged.packages)
];
}; };
systemPkgs = listToAttrs (map systemPkgs = listToAttrs (map
(system: nameValuePair system (pkgsFor system)) (system: nameValuePair system (pkgsFor system))
root'.systems); root'.systems);
genPackages = pkgs: mapAttrs (_: v: pkgs.callPackage v { }); getPackagesFrom = pkgs: packageSet:
genAttrs (attrNames packageSet) (p: pkgs.${p});
genMutualPackages = pkgs: packageSet:
let
overlay = final: _: genPackages final packageSet;
pkgs' = pkgs.extend overlay;
in
genAttrs (attrNames packageSet) (p: pkgs'.${p});
mkCheck = pkgs: name: cmd: pkgs.runCommand "check-${name}" { } '' mkCheck = pkgs: name: cmd: pkgs.runCommand "check-${name}" { } ''
cp --no-preserve=mode -r ${src} src cp --no-preserve=mode -r ${src} src
@ -175,7 +173,7 @@ let
(replaceDefault merged.packages); (replaceDefault merged.packages);
} // eachSystem (pkgs: rec { } // eachSystem (pkgs: rec {
packages = filterAttrs (_: supportedSystem pkgs) packages = filterAttrs (_: supportedSystem pkgs)
(genMutualPackages pkgs merged.packages); (getPackagesFrom pkgs merged.packages);
checks = mapAttrs' (k: nameValuePair ("packages-" + k)) packages; checks = mapAttrs' (k: nameValuePair ("packages-" + k)) packages;
}))) })))