mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
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.
This commit is contained in:
parent
84b1b01702
commit
79703eef08
@ -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 // {
|
||||
|
@ -33,6 +33,7 @@ let
|
||||
];
|
||||
specialArgs = {
|
||||
inherit config pkgs utils;
|
||||
class = "nixos";
|
||||
};
|
||||
};
|
||||
docs = import "${nixosPath}/doc/manual" {
|
||||
|
@ -40,7 +40,9 @@ let
|
||||
inherit prefix modules;
|
||||
specialArgs = {
|
||||
modulesPath = builtins.toString ../modules;
|
||||
} // specialArgs;
|
||||
} // specialArgs // {
|
||||
class = "nixos";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
@ -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 = [
|
||||
|
@ -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
|
||||
|
@ -82,6 +82,7 @@ in let
|
||||
config = config1;
|
||||
})
|
||||
];
|
||||
specialArgs.class = "nixpkgsConfig";
|
||||
};
|
||||
|
||||
# take all the rest as-is
|
||||
|
Loading…
Reference in New Issue
Block a user