mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/context: init with isDocs
Replaced the `isDocs` specialArg added in #1807 with an internal module option. We should only use `specialArgs` when absolutely necessary, a module or `_module.args` is preferred, but those aren't available until `config` is evaluated so they can't be used for `imports`. The main problem with `specialArgs` is it makes our modules less portable. Luckily that shouldn't be an issue for these context flags.
This commit is contained in:
parent
edc8602d47
commit
04a255ed7e
5 changed files with 20 additions and 6 deletions
|
@ -58,7 +58,10 @@ let
|
||||||
) opt.declarations;
|
) opt.declarations;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = [ ../modules/top-level ];
|
modules = [
|
||||||
|
../modules/top-level
|
||||||
|
{ isDocs = true; }
|
||||||
|
];
|
||||||
|
|
||||||
hmOptions = builtins.removeAttrs (lib.evalModules {
|
hmOptions = builtins.removeAttrs (lib.evalModules {
|
||||||
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
|
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
|
||||||
|
@ -73,7 +76,6 @@ rec {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit helpers;
|
inherit helpers;
|
||||||
defaultPkgs = pkgsDoc;
|
defaultPkgs = pkgsDoc;
|
||||||
isDocs = true;
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
options
|
options
|
||||||
|
|
|
@ -14,7 +14,6 @@ let
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit helpers;
|
inherit helpers;
|
||||||
defaultPkgs = pkgs;
|
defaultPkgs = pkgs;
|
||||||
isDocs = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
14
modules/misc/context.nix
Normal file
14
modules/misc/context.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
isDocs = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether modules are being evaluated to build documentation.
|
||||||
|
'';
|
||||||
|
internal = true;
|
||||||
|
visible = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./context.nix
|
||||||
./nixpkgs.nix
|
./nixpkgs.nix
|
||||||
./nixvim-info.nix
|
./nixvim-info.nix
|
||||||
(nixosModules + "/misc/assertions.nix")
|
(nixosModules + "/misc/assertions.nix")
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
helpers,
|
||||||
specialArgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
isDocs = specialArgs.isDocs or false;
|
|
||||||
|
|
||||||
fileModuleType = types.submoduleWith {
|
fileModuleType = types.submoduleWith {
|
||||||
shorthandOnlyDefinesConfig = true;
|
shorthandOnlyDefinesConfig = true;
|
||||||
|
@ -17,7 +15,7 @@ let
|
||||||
defaultPkgs = pkgs;
|
defaultPkgs = pkgs;
|
||||||
};
|
};
|
||||||
# Don't include the modules in the docs, as that'd be redundant
|
# Don't include the modules in the docs, as that'd be redundant
|
||||||
modules = lib.optionals (!isDocs) [
|
modules = lib.optionals (!config.isDocs) [
|
||||||
../../.
|
../../.
|
||||||
./submodule.nix
|
./submodule.nix
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue