Skip to content

Commit

Permalink
docs/home-manager: eval options without checking config definitions
Browse files Browse the repository at this point in the history
By default `lib.evalModules` will check all config definitions match
a declared option (or a freeform type), leading to errors like:

    error: The option `wrapRc' does not exist.

Setting `_module.freeformType` or `_module.check` will disable this,
allowing us to evaluate the option declaration without checking the
config definitions.
  • Loading branch information
MattSturgeon committed Sep 27, 2024
1 parent 6a1bf6b commit cb2b76c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 6 additions & 2 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ let
];
};

hmOptions = builtins.removeAttrs (lib.evalModules { modules = [ ../wrappers/modules/hm.nix ]; })
.options [ "_module" ];
hmOptions = builtins.removeAttrs (lib.evalModules {
modules = [
../wrappers/modules/hm.nix
{ _module.check = false; } # Ignore missing option declarations
];
}).options [ "_module" ];

options-json =
(pkgs.nixosOptionsDoc {
Expand Down
8 changes: 0 additions & 8 deletions wrappers/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ let
};
modules = [
./modules/hm.nix
# FIXME: this can't go in ./modules/hm.nix because we eval that module in the docs _without_ nixvim's modules
{
_file = ./hm.nix;
config = {
wrapRc = lib.mkOptionDefault false;
impureRtp = lib.mkOptionDefault true;
};
}
];
};
in
Expand Down
5 changes: 5 additions & 0 deletions wrappers/modules/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
};

imports = [ ./enable.nix ];

config = {
wrapRc = lib.mkOptionDefault false;
impureRtp = lib.mkOptionDefault true;
};
}

0 comments on commit cb2b76c

Please sign in to comment.