Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

nixos,nixpkgs: Add module classes

This allows modules that declare their class to be checked.
While that's not most user modules, frameworks can take advantage
of this by setting declaring the module class for their users.
That way, the mistake of importing a module into the wrong hierarchy
can be reported more clearly in some cases.

+14 -3
+4 -1
doc/doc-support/default.nix
··· 45 45 # NB: This file describes the Nixpkgs manual, which happens to use module 46 46 # docs infra originally developed for NixOS. 47 47 optionsDoc = pkgs.nixosOptionsDoc { 48 - inherit (pkgs.lib.evalModules { modules = [ ../../pkgs/top-level/config.nix ]; }) options; 48 + inherit (pkgs.lib.evalModules { 49 + modules = [ ../../pkgs/top-level/config.nix ]; 50 + specialArgs.class = "nixpkgsConfig"; 51 + }) options; 49 52 documentType = "none"; 50 53 transformOptions = opt: 51 54 opt // {
+1
nixos/lib/eval-cacheable-options.nix
··· 33 33 ]; 34 34 specialArgs = { 35 35 inherit config pkgs utils; 36 + class = "nixos"; 36 37 }; 37 38 }; 38 39 docs = import "${nixosPath}/doc/manual" {
+3 -1
nixos/lib/eval-config-minimal.nix
··· 40 40 inherit prefix modules; 41 41 specialArgs = { 42 42 modulesPath = builtins.toString ../modules; 43 - } // specialArgs; 43 + } // specialArgs // { 44 + class = "nixos"; 45 + }; 44 46 }; 45 47 46 48 in
+4 -1
nixos/lib/testing/default.nix
··· 1 1 { lib }: 2 2 let 3 3 4 - evalTest = module: lib.evalModules { modules = testModules ++ [ module ]; }; 4 + evalTest = module: lib.evalModules { 5 + modules = testModules ++ [ module ]; 6 + specialArgs.class = "nixosTest"; 7 + }; 5 8 runTest = module: (evalTest ({ config, ... }: { imports = [ module ]; result = config.test; })).config.result; 6 9 7 10 testModules = [
+1
nixos/modules/misc/documentation.nix
··· 39 39 _module.check = false; 40 40 } ] ++ docModules.eager; 41 41 specialArgs = specialArgs // { 42 + class = "nixos"; 42 43 pkgs = scrubDerivations "pkgs" pkgs; 43 44 # allow access to arbitrary options for eager modules, eg for getting 44 45 # option types from lazy modules
+1
pkgs/top-level/default.nix
··· 82 82 config = config1; 83 83 }) 84 84 ]; 85 + specialArgs.class = "nixpkgsConfig"; 85 86 }; 86 87 87 88 # take all the rest as-is