git.iko.soy/typeable/nixpkgs
on master help sign in
pkgs/top-level: check types of `nixpkgs.config`

This patch simply introduces a plain simple NixOS module and passes `nixpkgs.config` through it via `evalModules` (with some temporary hackery to passthru undefined options).

commit4a647dd225571e91d81c1306c69e3473fdd9a8c5 authorJan Malakhovski <oxij@oxij.org> dateSat 23 Feb 2019, 00:00 (8 years ago) parent570aed4
2 files changed+72−6
pkgs/top-level/config.nix+51 pkgs/top-level/default.nix+21−6
pkgs/top-level/config.nixnew file+51
@@ -0,0 +1,51 @@
1+# This file defines the structure of the `config` nixpkgs option.
2+
3+{ lib, config, ... }:
4+
5+with lib;
6+
7+let
8+
9+ mkMeta = args: mkOption (builtins.removeAttrs args [ "feature" ] // {
10+ type = args.type or (types.uniq types.bool);
11+ default = args.default or false;
12+ description = args.description or ''
13+ Whether to ${args.feature} while evaluating nixpkgs.
14+ '' + ''
15+ Changing the default will not cause any rebuilds.
16+ '';
17+ });
18+
19+ mkMassRebuild = args: mkOption (builtins.removeAttrs args [ "feature" ] // {
20+ type = args.type or (types.uniq types.bool);
21+ default = args.default or false;
22+ description = (args.description or ''
23+ Whether to ${args.feature} while building nixpkgs packages.
24+ '') + ''
25+ Changing the default will cause a mass rebuild.
26+ '';
27+ });
28+
29+ options = {
30+
31+ /* Internal stuff */
32+
33+ warnings = mkOption {
34+ type = types.listOf types.str;
35+ default = [];
36+ internal = true;
37+ };
38+
39+ /* Config options */
40+
41+ doCheckByDefault = mkMassRebuild {
42+ feature = "run <literal>checkPhase</literal> by default";
43+ };
44+
45+ };
46+
47+in {
48+
49+ inherit options;
50+
51+}
pkgs/top-level/default.nix+21−6
@@ -41,7 +41,7 @@
4141} @ args:
4242
4343let # Rename the function arguments
44− configExpr = config;
44+ config0 = config;
4545 crossSystem0 = crossSystem;
4646
4747in let
@@ -50,22 +50,37 @@ in let
5050 # Allow both:
5151 # { /* the config */ } and
5252 # { pkgs, ... } : { /* the config */ }
53− config =
54− if lib.isFunction configExpr
55− then configExpr { inherit pkgs; }
56− else configExpr;
53+ config1 =
54+ if lib.isFunction config0
55+ then config0 { inherit pkgs; }
56+ else config0;
5757
5858 # From a minimum of `system` or `config` (actually a target triple, *not*
5959 # nixpkgs configuration), infer the other one and platform as needed.
6060 localSystem = lib.systems.elaborate (
6161 # Allow setting the platform in the config file. This take precedence over
6262 # the inferred platform, but not over an explicitly passed-in one.
63− builtins.intersectAttrs { platform = null; } config
63+ builtins.intersectAttrs { platform = null; } config1
6464 // args.localSystem);
6565
6666 crossSystem = if crossSystem0 == null then localSystem
6767 else lib.systems.elaborate crossSystem0;
6868
69+ configEval = lib.evalModules {
70+ modules = [
71+ ./config.nix
72+ ({ options, ... }: {
73+ _file = "nixpkgs.config";
74+ # filter-out known options, FIXME: remove this eventually
75+ config = builtins.intersectAttrs options config1;
76+ })
77+ ];
78+ };
79+
80+ # take all the rest as-is
81+ config = lib.showWarnings configEval.config.warnings
82+ (config1 // builtins.removeAttrs configEval.config [ "_module" ]);
83+
6984 # A few packages make a new package set to draw their dependencies from.
7085 # (Currently to get a cross tool chain, or forced-i686 package.) Rather than
7186 # give `all-packages.nix` all the arguments to this function, even ones that