mirror of
https://github.com/nix-community/nixvim.git
synced 2025-12-13 20:41:09 +01:00
wrappers: expose platform wrapper modules via build.*Module options
Expose the platform wrapper modules as the Nixvim configuration options `build.nixosModule`, `build.homeModule`, and `build.nixDarwinModule`. This makes it possible to reuse a single Nixvim configuration across NixOS, Home Manager, and nix-darwin without re-importing modules into `programs.nixvim` manually. Evaluating these wrapper modules requires a "bare" Nixvim configuration; one that does not define `pkgs` or `nixpkgs.hostPlatform`. Such a configuration would normally fail to evaluate, but disabling `_module.check` provides a sufficiently lazy evaluation to access the wrapper options. To prevent the `_module.check = false` module from leaking into user configs, it has a unique module key and gets disabled inside the wrapper modules (`wrappers/_shared.nix`).
This commit is contained in:
parent
05c57f2e74
commit
53b702b367
7 changed files with 110 additions and 44 deletions
40
modules/wrappers.nix
Normal file
40
modules/wrappers.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
lib,
|
||||
extendModules,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.build = {
|
||||
nixosModule = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
description = "A NixOS module that installs this Nixvim configuration.";
|
||||
readOnly = true;
|
||||
};
|
||||
homeModule = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
description = "A Home Manager module that installs this Nixvim configuration.";
|
||||
readOnly = true;
|
||||
};
|
||||
nixDarwinModule = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
description = "A nix-darwin module that installs this Nixvim configuration.";
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
|
||||
config.build = {
|
||||
nixosModule = lib.modules.importApply ../wrappers/nixos.nix {
|
||||
self = config.flake;
|
||||
inherit extendModules;
|
||||
};
|
||||
homeModule = lib.modules.importApply ../wrappers/hm.nix {
|
||||
self = config.flake;
|
||||
inherit extendModules;
|
||||
};
|
||||
nixDarwinModule = lib.modules.importApply ../wrappers/darwin.nix {
|
||||
self = config.flake;
|
||||
inherit extendModules;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue