wrappers: encapsulate access to lib.nixvim and lib-overlay

- Pass only `evalNixvim` into standalone.nix.
- Access Nixvim lib via the submodule configuration in _shared.nix.
This commit is contained in:
Matt Sturgeon
2026-05-24 03:05:36 +00:00
parent fca03f1759
commit e1ad5c4e92
7 changed files with 27 additions and 29 deletions
+2 -1
View File
@@ -34,7 +34,8 @@ in
{
legacyPackages = {
makeNixvimWithModule = import ../wrappers/standalone.nix {
inherit lib self;
inherit lib;
inherit (self.lib) evalNixvim;
defaultSystem = system;
};
makeNixvim = module: makeNixvimWithModule { inherit module; };
+7 -14
View File
@@ -1,9 +1,11 @@
{
lib,
extendModules,
config,
...
}:
let
importWrapper = lib.flip lib.modules.importApply { inherit extendModules; };
in
{
options.build = {
nixosModule = lib.mkOption {
@@ -23,18 +25,9 @@
};
};
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;
};
config.build = lib.mapAttrs (_: importWrapper) {
nixosModule = ../wrappers/nixos.nix;
homeModule = ../wrappers/hm.nix;
nixDarwinModule = ../wrappers/darwin.nix;
};
}
+16 -6
View File
@@ -1,6 +1,4 @@
{
# The nixvim flake
self,
# Function used to evaluate the `programs.nixvim` configuration
extendModules,
# Option path where extraFiles should go
@@ -15,6 +13,7 @@
pkgs,
lib,
config,
options,
...
}:
let
@@ -24,7 +23,12 @@ let
optionalAttrs
setAttrByPath
;
cfg = config.programs.nixvim;
opts = finalConfiguration.options;
flake = lib.optionalAttrs opts.flake.isDefined cfg.flake;
libOverlay = flake.lib.overlay or (import ../lib/overlay.nix);
# FIXME: buildPlatform can't use mkOptionDefault because it already defaults to hostPlatform
buildPlatformPrio = (lib.mkOptionDefault null).priority - 1;
@@ -43,20 +47,26 @@ let
};
};
nixvimConfiguration = extendModules {
baseConfiguration = extendModules {
modules = [
nixpkgsModule
{ disabledModules = [ "<internal:nixvim-nocheck-base-eval>" ]; }
];
};
finalConfiguration =
options.programs.nixvim.valueMeta.configuration or (throw
# v2 check+merge was added 2025-08-28, halfway through the 25.11 cycle
"`${options.programs.nixvim}` was evaluated using Nixpkgs lib ${lib.trivial.release}, which does not support `valueMeta` added in Nixpkgs 25.11."
);
extraFiles = lib.filter (file: file.enable) (lib.attrValues cfg.extraFiles);
in
{
_file = ./_shared.nix;
options.programs.nixvim = lib.mkOption {
inherit (nixvimConfiguration) type;
inherit (baseConfiguration) type;
default = { };
};
@@ -76,8 +86,8 @@ in
# NOTE: It is important that we use the flake-locked Nixpkgs lib,
# so that we can safely use recently added lib features.
# TODO: Consider deprecating `_module.args.nixvimLib`?
lib.nixvim = lib.mkDefault self.lib.nixvim;
_module.args.nixvimLib = lib.mkDefault (lib.extend self.lib.overlay);
lib.nixvim = lib.mkDefault finalConfiguration._module.specialArgs.lib.nixvim;
_module.args.nixvimLib = lib.mkDefault (lib.extend libOverlay);
}
# Propagate nixvim's assertions to the host modules
-2
View File
@@ -1,5 +1,4 @@
{
self,
extendModules,
}:
{
@@ -21,7 +20,6 @@ in
imports = [
(importApply ./_shared.nix {
inherit self;
inherit
(extendModules {
specialArgs.darwinConfig = config;
-2
View File
@@ -1,5 +1,4 @@
{
self,
extendModules,
}:
{
@@ -18,7 +17,6 @@ in
imports = [
(import ./_shared.nix {
inherit self;
inherit
(extendModules {
specialArgs.hmConfig = config;
-2
View File
@@ -1,5 +1,4 @@
{
self,
extendModules,
}:
{
@@ -18,7 +17,6 @@ in
imports = [
(import ./_shared.nix {
inherit self;
inherit
(extendModules {
specialArgs.nixosConfig = config;
+2 -2
View File
@@ -1,7 +1,7 @@
{
self,
lib,
defaultSystem,
evalNixvim,
}:
{
# TODO: Deprecate this arg in favour of using module options
@@ -29,7 +29,7 @@ let
mod:
let
modules = lib.toList mod;
nixvimConfig = self.lib.evalNixvim {
nixvimConfig = evalNixvim {
modules = modules ++ [
systemMod
];