diff --git a/pkgs/modules/module-list.nix b/pkgs/modules/module-list.nix new file mode 100644 index 0000000000000..7f5061e6aedea --- /dev/null +++ b/pkgs/modules/module-list.nix @@ -0,0 +1,3 @@ +[ + ./overrides.nix +] diff --git a/pkgs/modules/overrides.nix b/pkgs/modules/overrides.nix new file mode 100644 index 0000000000000..7dbb085badedd --- /dev/null +++ b/pkgs/modules/overrides.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + isConfig = x: + builtins.isAttrs x || builtins.isFunction x; + configType = mkOptionType { + name = "nixpkgs config"; + check = traceValIfNot isConfig; + }; +in + +{ + options = { + packageOverrides = mkOption { + type = configType; + description = "Package overrides"; + }; + }; +} diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index cff8671b65d57..66887af1f0906 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -35,9 +35,6 @@ let lib = import ../../lib; - # The contents of the configuration file found at $NIXPKGS_CONFIG or - # $HOME/.nixpkgs/config.nix. - # for NIXOS (nixos-rebuild): use nixpkgs.config option config = let inherit (builtins) getEnv pathExists; @@ -46,19 +43,16 @@ let homeDir = getEnv "HOME"; configFile2 = homeDir + "/.nixpkgs/config.nix"; - configExpr = + rootModule = if config_ != null then config_ - else if configFile != "" && pathExists configFile then import configFile - else if homeDir != "" && pathExists configFile2 then import configFile2 - else {}; + else if configFile != "" && pathExists configFile then [ configFile ] + else if homeDir != "" && pathExists configFile2 then [ configFile2 ] + else []; in - # allow both: - # { /* the config */ } and - # { pkgs, ... } : { /* the config */ } - if builtins.isFunction configExpr - then configExpr { inherit pkgs; } - else configExpr; + (lib.evalModules { + modules = rootModule ++ import ../modules/module-list.nix; + }).config; # Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc)