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
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
# The nixvim flake
|
||||
self,
|
||||
# Extra args for the `evalNixvim` call that produces the type for `programs.nixvim`
|
||||
evalArgs ? { },
|
||||
# Function used to evaluate the `programs.nixvim` configuration
|
||||
extendModules,
|
||||
# Option path where extraFiles should go
|
||||
filesOpt ? null,
|
||||
# Filepath prefix to apply to extraFiles
|
||||
|
|
@ -45,14 +45,13 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
nixvimConfiguration = config.lib.nixvim.modules.evalNixvim (
|
||||
evalArgs
|
||||
// {
|
||||
modules = evalArgs.modules or [ ] ++ [
|
||||
nixpkgsModule
|
||||
];
|
||||
}
|
||||
);
|
||||
nixvimConfiguration = extendModules {
|
||||
modules = [
|
||||
nixpkgsModule
|
||||
{ disabledModules = [ "<internal:nixvim-nocheck-base-eval>" ]; }
|
||||
];
|
||||
};
|
||||
|
||||
extraFiles = lib.filter (file: file.enable) (lib.attrValues cfg.extraFiles);
|
||||
in
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
self:
|
||||
{
|
||||
self,
|
||||
extendModules,
|
||||
}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
|
|
@ -12,19 +15,22 @@ let
|
|||
importApply
|
||||
;
|
||||
cfg = config.programs.nixvim;
|
||||
evalArgs = {
|
||||
extraSpecialArgs = {
|
||||
darwinConfig = config;
|
||||
};
|
||||
modules = [
|
||||
./modules/darwin.nix
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
_file = ./darwin.nix;
|
||||
|
||||
imports = [ (importApply ./_shared.nix { inherit self evalArgs; }) ];
|
||||
imports = [
|
||||
(importApply ./_shared.nix {
|
||||
inherit self;
|
||||
inherit
|
||||
(extendModules {
|
||||
specialArgs.darwinConfig = config;
|
||||
modules = [ ./modules/darwin.nix ];
|
||||
})
|
||||
extendModules
|
||||
;
|
||||
})
|
||||
];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
self:
|
||||
{
|
||||
self,
|
||||
extendModules,
|
||||
}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
|
|
@ -9,21 +12,20 @@ let
|
|||
mkIf
|
||||
;
|
||||
cfg = config.programs.nixvim;
|
||||
evalArgs = {
|
||||
extraSpecialArgs = {
|
||||
hmConfig = config;
|
||||
};
|
||||
modules = [
|
||||
./modules/hm.nix
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
_file = ./hm.nix;
|
||||
|
||||
imports = [
|
||||
(import ./_shared.nix {
|
||||
inherit self evalArgs;
|
||||
inherit self;
|
||||
inherit
|
||||
(extendModules {
|
||||
specialArgs.hmConfig = config;
|
||||
modules = [ ./modules/hm.nix ];
|
||||
})
|
||||
extendModules
|
||||
;
|
||||
filesOpt = [
|
||||
"xdg"
|
||||
"configFile"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
self:
|
||||
{
|
||||
self,
|
||||
extendModules,
|
||||
}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
|
|
@ -9,21 +12,20 @@ let
|
|||
mkIf
|
||||
;
|
||||
cfg = config.programs.nixvim;
|
||||
evalArgs = {
|
||||
extraSpecialArgs = {
|
||||
nixosConfig = config;
|
||||
};
|
||||
modules = [
|
||||
./modules/nixos.nix
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
_file = ./nixos.nix;
|
||||
|
||||
imports = [
|
||||
(import ./_shared.nix {
|
||||
inherit self evalArgs;
|
||||
inherit self;
|
||||
inherit
|
||||
(extendModules {
|
||||
specialArgs.nixosConfig = config;
|
||||
modules = [ ./modules/nixos.nix ];
|
||||
})
|
||||
extendModules
|
||||
;
|
||||
filesOpt = [
|
||||
"environment"
|
||||
"etc"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue