diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 516fdd8d33fd..5575e9577029 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -248,7 +248,7 @@ rec {
/* Apply fold functions to values grouped by key.
Example:
- foldAttrs (n: a: [n] ++ a) [] [{ a = 2; } { a = 3; }]
+ foldAttrs (item: acc: [item] ++ acc) [] [{ a = 2; } { a = 3; }]
=> { a = [ 2 3 ]; }
*/
foldAttrs = op: nul:
diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix
index 853e6c76ab54..ad06227e74f1 100644
--- a/pkgs/top-level/config.nix
+++ b/pkgs/top-level/config.nix
@@ -1,6 +1,6 @@
# This file defines the structure of the `config` nixpkgs option.
-{ lib, ... }:
+{ config, lib, ... }:
with lib;
@@ -33,6 +33,11 @@ let
/* Config options */
+ warnUndeclaredOptions = mkOption {
+ description = "Whether to warn when config contains an unrecognized attribute.";
+ default = false;
+ };
+
doCheckByDefault = mkMassRebuild {
feature = "run checkPhase by default";
};
@@ -122,6 +127,20 @@ let
in {
+ freeformType =
+ let t = lib.types.attrsOf lib.types.raw;
+ in t // {
+ merge = loc: defs:
+ let r = t.merge loc defs;
+ in r // { _undeclared = r; };
+ };
+
inherit options;
+ config = {
+ warnings = lib.optionals config.warnUndeclaredOptions (
+ lib.mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared
+ );
+ };
+
}
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix
index e95a0db78c3c..b32aabc3a1fd 100644
--- a/pkgs/top-level/default.nix
+++ b/pkgs/top-level/default.nix
@@ -79,15 +79,13 @@ in let
./config.nix
({ options, ... }: {
_file = "nixpkgs.config";
- # filter-out known options, FIXME: remove this eventually
- config = builtins.intersectAttrs options config1;
+ config = config1;
})
];
};
# take all the rest as-is
- config = lib.showWarnings configEval.config.warnings
- (config1 // builtins.removeAttrs configEval.config [ "_module" ]);
+ config = lib.showWarnings configEval.config.warnings configEval.config;
# A few packages make a new package set to draw their dependencies from.
# (Currently to get a cross tool chain, or forced-i686 package.) Rather than