diff --git a/modules/nixpkgs.nix b/modules/nixpkgs.nix index 0f91f77..c33aea4 100644 --- a/modules/nixpkgs.nix +++ b/modules/nixpkgs.nix @@ -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; + }; + }); + }; }