mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 20:55:31 +03:00
pkgs/top-level/config.nix: Add warnUndeclaredOptions
This commit is contained in:
parent
4d2237c841
commit
596b3663a5
2 changed files with 17 additions and 5 deletions
|
@ -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;
|
||||||
|
|
||||||
|
@ -28,6 +28,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";
|
||||||
};
|
};
|
||||||
|
@ -113,6 +118,15 @@ let
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
|
freeformType =
|
||||||
|
let t = lib.types.attrsOf lib.types.raw;
|
||||||
|
in t // {
|
||||||
|
merge = loc: defs:
|
||||||
|
lib.mapAttrs
|
||||||
|
(k: v: lib.warnIf config.warnUndeclaredOptions "undeclared Nixpkgs option set: config.${k}" v)
|
||||||
|
(t.merge loc defs);
|
||||||
|
};
|
||||||
|
|
||||||
inherit options;
|
inherit options;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue