diff --git a/lib/modules.nix b/lib/modules.nix index 74021171b9..c45685b2b4 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -14,6 +14,12 @@ let applyExtraConfig = "It has been moved to `lib.plugins.utils`"; mkConfigAt = "It has been moved to `lib.plugins.utils`"; }; + + wrapEvalNixvim = + pred: fn: + lib.mirrorFunctionArgs self.modules.evalNixvim ( + input: fn (if pred input then input else self.modules.evalNixvim input) + ); in { # Evaluate nixvim modules, checking warnings and assertions @@ -57,6 +63,48 @@ in } // extraSpecialArgs; }; + + /** + Build a Nixvim package. + + This is a thin wrapper around `.config.build.package`. + + # Inputs + + `input` + : One of: + 1. Arguments for `evalNixvim`. + 2. A Nixvim configuration, as produced by `evalNixvim`. + 3. A Nixvim package, as produced by `buildNixvim`. + + # Output + + An installable Nixvim package. + */ + buildNixvim = wrapEvalNixvim (input: input ? config.build.package) ( + configuration: configuration.config.build.package + ); + + /** + Build a Nixvim test derivation. + + This is a thin wrapper around `.config.build.test`. + + # Inputs + + `input` + : One of: + 1. Arguments for `evalNixvim`. + 2. A Nixvim configuration, as produced by `evalNixvim`. + 3. A Nixvim package, as produced by `buildNixvim`. + + # Output + + A buildable Nixvim test. + */ + testNixvim = wrapEvalNixvim (input: input ? config.build.test) ( + configuration: configuration.config.build.test + ); } // lib.mapAttrs ( name: msg: 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 { diff --git a/tests/lib-tests.nix b/tests/lib-tests.nix index 694e2f5af2..485084ffe8 100644 --- a/tests/lib-tests.nix +++ b/tests/lib-tests.nix @@ -546,6 +546,16 @@ let "Nixvim (single-element): Trailing whitespaces" ]; }; + + buildNixvim_hasExpectedArgs = { + expr = lib.functionArgs lib.nixvim.modules.buildNixvim; + expected = lib.functionArgs lib.nixvim.modules.evalNixvim; + }; + + testNixvim_hasExpectedArgs = { + expr = lib.functionArgs lib.nixvim.modules.testNixvim; + expected = lib.functionArgs lib.nixvim.modules.evalNixvim; + }; }; in if results == [ ] then