1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-12 12:01:10 +01:00
nixvim/wrappers/hm.nix
Matt Sturgeon 53b702b367 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`).
2025-12-09 08:01:49 +00:00

49 lines
798 B
Nix

{
self,
extendModules,
}:
{
config,
lib,
...
}:
let
inherit (lib)
mkIf
;
cfg = config.programs.nixvim;
in
{
_file = ./hm.nix;
imports = [
(import ./_shared.nix {
inherit self;
inherit
(extendModules {
specialArgs.hmConfig = config;
modules = [ ./modules/hm.nix ];
})
extendModules
;
filesOpt = [
"xdg"
"configFile"
];
})
];
config = mkIf cfg.enable {
home.packages = [
cfg.build.package
];
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
programs = mkIf cfg.vimdiffAlias {
bash.shellAliases.vimdiff = "nvim -d";
fish.shellAliases.vimdiff = "nvim -d";
zsh.shellAliases.vimdiff = "nvim -d";
};
};
}