1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-25 03:39:40 +01:00

wrappers: use importApply to preserve module location

The `import module args` pattern is useful for applying inputs from
outside of the module system, however it discards module location
metadata that is usually associated with file-path modules.

`lib.modules.importApply` solves that problem by wrapping the applied
module using `lib.modules.setDefaultModuleLocation`.

This means documentation, warnings, and errors will show the correct
location.
This commit is contained in:
Matt Sturgeon 2025-11-24 10:41:21 +00:00
parent 453fe40893
commit 947cb0aaed
2 changed files with 10 additions and 4 deletions

View file

@ -3,6 +3,9 @@
lib,
...
}:
let
inherit (lib.modules) importApply;
in
{
perSystem =
{ system, ... }:
@ -17,7 +20,7 @@
flake = {
nixosModules = {
nixvim = import ../wrappers/nixos.nix self;
nixvim = importApply ../wrappers/nixos.nix self;
default = self.nixosModules.nixvim;
};
# Alias for backward compatibility
@ -29,11 +32,11 @@
in
lib.warnIf cond msg self.homeModules;
homeModules = {
nixvim = import ../wrappers/hm.nix self;
nixvim = importApply ../wrappers/hm.nix self;
default = self.homeModules.nixvim;
};
nixDarwinModules = {
nixvim = import ../wrappers/darwin.nix self;
nixvim = importApply ../wrappers/darwin.nix self;
default = self.nixDarwinModules.nixvim;
};
};

View file

@ -8,6 +8,9 @@ let
inherit (lib)
mkIf
;
inherit (lib.modules)
importApply
;
cfg = config.programs.nixvim;
evalArgs = {
extraSpecialArgs = {
@ -21,7 +24,7 @@ in
{
_file = ./darwin.nix;
imports = [ (import ./_shared.nix { inherit self evalArgs; }) ];
imports = [ (importApply ./_shared.nix { inherit self evalArgs; }) ];
config = mkIf cfg.enable {
environment.systemPackages = [