Merge pull request #171014 from hercules-ci/nixpkgs-warn-undeclared-options
pkgs/top-level/config.nix: Add warnUndeclaredOptions
This commit is contained in:
commit
40b6089f21
@ -248,7 +248,7 @@ rec {
|
|||||||
/* Apply fold functions to values grouped by key.
|
/* Apply fold functions to values grouped by key.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
foldAttrs (n: a: [n] ++ a) [] [{ a = 2; } { a = 3; }]
|
foldAttrs (item: acc: [item] ++ acc) [] [{ a = 2; } { a = 3; }]
|
||||||
=> { a = [ 2 3 ]; }
|
=> { a = [ 2 3 ]; }
|
||||||
*/
|
*/
|
||||||
foldAttrs = op: nul:
|
foldAttrs = op: nul:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# This file defines the structure of the `config` nixpkgs option.
|
# This file defines the structure of the `config` nixpkgs option.
|
||||||
|
|
||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
@ -33,6 +33,11 @@ let
|
|||||||
|
|
||||||
/* Config options */
|
/* Config options */
|
||||||
|
|
||||||
|
warnUndeclaredOptions = mkOption {
|
||||||
|
description = "Whether to warn when <literal>config</literal> contains an unrecognized attribute.";
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
doCheckByDefault = mkMassRebuild {
|
doCheckByDefault = mkMassRebuild {
|
||||||
feature = "run <literal>checkPhase</literal> by default";
|
feature = "run <literal>checkPhase</literal> by default";
|
||||||
};
|
};
|
||||||
@ -122,6 +127,20 @@ let
|
|||||||
|
|
||||||
in {
|
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;
|
inherit options;
|
||||||
|
|
||||||
|
config = {
|
||||||
|
warnings = lib.optionals config.warnUndeclaredOptions (
|
||||||
|
lib.mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,15 +79,13 @@ in let
|
|||||||
./config.nix
|
./config.nix
|
||||||
({ options, ... }: {
|
({ options, ... }: {
|
||||||
_file = "nixpkgs.config";
|
_file = "nixpkgs.config";
|
||||||
# filter-out known options, FIXME: remove this eventually
|
config = config1;
|
||||||
config = builtins.intersectAttrs options config1;
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# take all the rest as-is
|
# take all the rest as-is
|
||||||
config = lib.showWarnings configEval.config.warnings
|
config = lib.showWarnings configEval.config.warnings configEval.config;
|
||||||
(config1 // builtins.removeAttrs configEval.config [ "_module" ]);
|
|
||||||
|
|
||||||
# A few packages make a new package set to draw their dependencies from.
|
# 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
|
# (Currently to get a cross tool chain, or forced-i686 package.) Rather than
|
||||||
|
Loading…
Reference in New Issue
Block a user