1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2025-03-31 04:04:55 +00:00

(workingTest (nixpkgsFlakeOverlays [mkFlake perSystem]))

This commit is contained in:
li 2023-03-23 15:13:19 +07:00
parent 12c40901ba
commit 9c9ec49c19
No known key found for this signature in database
GPG key ID: 4372E1E8D7C5FCC5

View file

@ -3,32 +3,33 @@
#
# Provides a `pkgs` argument in `perSystem`.
#
# Arguably, this shouldn't be in flake-parts, but in nixpkgs.
# Nixpkgs could define its own module that does this, which would be
# a more consistent UX, but for now this will do.
#
# The existence of this module does not mean that other flakes' logic
# will be accepted into flake-parts, because it's against the
# spirit of Flakes.
#
topLevel@{ config, options, inputs, lib, flake-parts-lib, ... }:
let
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
imports = [ inputs.nixpkgs.flakeModules.default ];
options = {
perSystem = mkPerSystemOption ({ config, system, ... }: {
_file = ./nixpkgs.nix;
imports = [{ inherit (topLevel.config) nixpkgs; }];
options = { inherit (options) nixpkgs; };
config = {
_module.args.pkgs = lib.mkDefault (config.nixpkgs.allPkgsPerSystem.${system});
};
});
};
perSystem = mkPerSystemOption ({ config, system, ... }:
let
finalOverlay = lib.composeManyExtensions
# Last element has priority, so `perSystem` overlays rule
(topLevel.config.nixpkgs.overlays ++ config.nixpkgs.overlays);
finalPkgs = config.nixpkgs.mkPkgsFromArgs
{ inherit system; overlays = [ finalOverlay ]; };
in
{
imports = [ inputs.nixpkgs.flakeModules.default ];
_file = ./nixpkgs.nix;
config = {
_module.args.pkgs = lib.mkForce finalPkgs;
};
});
};
}