1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-16 14:01:10 +01:00

lib/modules: init buildNixvim and buildNixvimWith

Introduce thin wrappers around the `<configuration>.config.build.package`,
option intended to replace the legacy `makeNixvim` and
`makeNixvimWithModule` functions.
This commit is contained in:
Matt Sturgeon 2025-11-21 12:23:42 +00:00
parent a250540213
commit 2695bef079
2 changed files with 46 additions and 0 deletions

View file

@ -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:

View file

@ -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