diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-04-10 17:55:34 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-05-06 18:29:04 +0200 |
commit | 79703eef083d70046873dbb86f08e2ff08f58197 (patch) | |
tree | 262d6370ef51132a9c08fa71d4ce1dba71b6a770 | |
parent | 84b1b017026bb1d0a37a8d3ef553f073225b4e8d (diff) | |
download | nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar.gz nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar.bz2 nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar.lz nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar.xz nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.tar.zst nixpkgs-79703eef083d70046873dbb86f08e2ff08f58197.zip |
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.
-rw-r--r-- | doc/doc-support/default.nix | 5 | ||||
-rw-r--r-- | nixos/lib/eval-cacheable-options.nix | 1 | ||||
-rw-r--r-- | nixos/lib/eval-config-minimal.nix | 4 | ||||
-rw-r--r-- | nixos/lib/testing/default.nix | 5 | ||||
-rw-r--r-- | nixos/modules/misc/documentation.nix | 1 | ||||
-rw-r--r-- | pkgs/top-level/default.nix | 1 |
6 files changed, 14 insertions, 3 deletions
diff --git a/doc/doc-support/default.nix b/doc/doc-support/default.nix index bea3e12a70b..67195a4a58b 100644 --- a/doc/doc-support/default.nix +++ b/doc/doc-support/default.nix @@ -45,7 +45,10 @@ let # NB: This file describes the Nixpkgs manual, which happens to use module # docs infra originally developed for NixOS. optionsDoc = pkgs.nixosOptionsDoc { - inherit (pkgs.lib.evalModules { modules = [ ../../pkgs/top-level/config.nix ]; }) options; + inherit (pkgs.lib.evalModules { + modules = [ ../../pkgs/top-level/config.nix ]; + specialArgs.class = "nixpkgsConfig"; + }) options; documentType = "none"; transformOptions = opt: opt // { diff --git a/nixos/lib/eval-cacheable-options.nix b/nixos/lib/eval-cacheable-options.nix index c3ba2ce6637..d26967ebe09 100644 --- a/nixos/lib/eval-cacheable-options.nix +++ b/nixos/lib/eval-cacheable-options.nix @@ -33,6 +33,7 @@ let ]; specialArgs = { inherit config pkgs utils; + class = "nixos"; }; }; docs = import "${nixosPath}/doc/manual" { diff --git a/nixos/lib/eval-config-minimal.nix b/nixos/lib/eval-config-minimal.nix index d45b9ffd426..7e28f430512 100644 --- a/nixos/lib/eval-config-minimal.nix +++ b/nixos/lib/eval-config-minimal.nix @@ -40,7 +40,9 @@ let inherit prefix modules; specialArgs = { modulesPath = builtins.toString ../modules; - } // specialArgs; + } // specialArgs // { + class = "nixos"; + }; }; in diff --git a/nixos/lib/testing/default.nix b/nixos/lib/testing/default.nix index 9d4f9dbc43d..1bd6278ce68 100644 --- a/nixos/lib/testing/default.nix +++ b/nixos/lib/testing/default.nix @@ -1,7 +1,10 @@ { lib }: let - evalTest = module: lib.evalModules { modules = testModules ++ [ module ]; }; + evalTest = module: lib.evalModules { + modules = testModules ++ [ module ]; + specialArgs.class = "nixosTest"; + }; runTest = module: (evalTest ({ config, ... }: { imports = [ module ]; result = config.test; })).config.result; testModules = [ diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index e0c6af4abe1..1821dd866cb 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -39,6 +39,7 @@ let _module.check = false; } ] ++ docModules.eager; specialArgs = specialArgs // { + class = "nixos"; pkgs = scrubDerivations "pkgs" pkgs; # allow access to arbitrary options for eager modules, eg for getting # option types from lazy modules diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index b32aabc3a1f..f54ce84aeda 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -82,6 +82,7 @@ in let config = config1; }) ]; + specialArgs.class = "nixpkgsConfig"; }; # take all the rest as-is |