From f09e08f867af45bf29494a777492083e094db2f0 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 21 Nov 2025 12:48:21 +0000 Subject: [PATCH 1/3] modules/output: include `config` and `options` in `build.package` Similar to the legacy "standalone wrapper" `makeNixvimWithModule`, thread the configuration's `config` and `options` to the final package. This allows using such a package as the input to functions like `testNixvim`. --- modules/top-level/output.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/top-level/output.nix b/modules/top-level/output.nix index e41be4161d..df59014983 100644 --- a/modules/top-level/output.nix +++ b/modules/top-level/output.nix @@ -1,6 +1,7 @@ { pkgs, config, + options, lib, ... }: @@ -319,6 +320,9 @@ in printInitPackage ]; meta.mainProgram = "nvim"; + passthru = { + inherit config options; + }; }; printInitPackage = pkgs.writeShellApplication { From 086c2687951c6bd9c77651ba6896d464802d2df0 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 21 Nov 2025 12:23:42 +0000 Subject: [PATCH 2/3] lib/modules: init `buildNixvim` and `buildNixvimWith` Introduce thin wrappers around the `.config.build.package`, option intended to replace the legacy `makeNixvim` and `makeNixvimWithModule` functions. --- lib/modules.nix | 41 +++++++++++++++++++++++++++++++++++++++++ tests/lib-tests.nix | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/lib/modules.nix b/lib/modules.nix index 74021171b9..09d12f7ed7 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -57,6 +57,47 @@ in } // extraSpecialArgs; }; + + /** + Build a Nixvim package. + + # Inputs + + `input` + : One of: + 1. A Nixvim module or a list of modules. + 2. A Nixvim configuration. + 3. A Nixvim package. + + # Output + + An installable Nixvim package. + */ + buildNixvim = + input: + if lib.isDerivation input then + lib.throwIfNot (input ? config.build.package) + "buildNixvim: received a derivation without the expected `config` attribute." + input.config.build.package + else if lib.isType "configuration" input then + lib.throwIfNot (input ? config.build.package) + "buildNixvim: received a configuration without the expected `build.package` option." + input.config.build.package + else + self.modules.buildNixvimWith { + modules = lib.toList input; + }; + + /** + Build a Nixvim package using the same interface as `evalNixvim`. + + # Output + + An installable Nixvim package. + */ + buildNixvimWith = lib.mirrorFunctionArgs self.modules.evalNixvim ( + args: (self.modules.evalNixvim args).config.build.package + ); } // lib.mapAttrs ( name: msg: diff --git a/tests/lib-tests.nix b/tests/lib-tests.nix index 694e2f5af2..bbce4eaf81 100644 --- a/tests/lib-tests.nix +++ b/tests/lib-tests.nix @@ -546,6 +546,11 @@ let "Nixvim (single-element): Trailing whitespaces" ]; }; + + buildNixvimWith_hasExpectedArgs = { + expr = lib.functionArgs lib.nixvim.modules.buildNixvimWith; + expected = lib.functionArgs lib.nixvim.modules.evalNixvim; + }; }; in if results == [ ] then From 6fc9a1fd68c0c0fea39c121fb2a6d38b9accee9a Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 21 Nov 2025 12:30:08 +0000 Subject: [PATCH 3/3] lib/modules: init `testNixvim` and `testNixvimWith` Introduce thin wrappers around the `.config.build.test` option, intended to replace the legacy `mkTestDerivationFromNvim` and `mkTestDerivationFromNixvimModule` functions. --- lib/modules.nix | 41 +++++++++++++++++++++++++++++++++++++++++ tests/lib-tests.nix | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/lib/modules.nix b/lib/modules.nix index 09d12f7ed7..95cf5f8218 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -98,6 +98,47 @@ in buildNixvimWith = lib.mirrorFunctionArgs self.modules.evalNixvim ( args: (self.modules.evalNixvim args).config.build.package ); + + /** + Build a Nixvim test derivation. + + # Inputs + + `input` + : One of: + 1. A Nixvim module or a list of modules. + 2. A Nixvim configuration. + 3. A Nixvim package. + + # Output + + A buildable Nixvim test. + */ + testNixvim = + input: + if lib.isDerivation input then + lib.throwIfNot (input ? config.build.test) + "testNixvim: received a derivation without the expected `config` attribute." + input.config.build.test + else if lib.isType "configuration" input then + lib.throwIfNot (input ? config.build.test) + "testNixvim: received a configuration without the expected `build.test` option." + input.config.build.test + else + self.modules.testNixvimWith { + modules = lib.toList input; + }; + + /** + Build a Nixvim test derivation using the same interface as `evalNixvim`. + + # Output + + A buildable Nixvim test. + */ + testNixvimWith = lib.mirrorFunctionArgs self.modules.evalNixvim ( + args: (self.modules.evalNixvim args).config.build.test + ); } // lib.mapAttrs ( name: msg: diff --git a/tests/lib-tests.nix b/tests/lib-tests.nix index bbce4eaf81..f273463468 100644 --- a/tests/lib-tests.nix +++ b/tests/lib-tests.nix @@ -551,6 +551,11 @@ let expr = lib.functionArgs lib.nixvim.modules.buildNixvimWith; expected = lib.functionArgs lib.nixvim.modules.evalNixvim; }; + + testNixvimWith_hasExpectedArgs = { + expr = lib.functionArgs lib.nixvim.modules.testNixvimWith; + expected = lib.functionArgs lib.nixvim.modules.evalNixvim; + }; }; in if results == [ ] then