nix-community.nixvim/wrappers/standalone.nix
Matt Sturgeon 4b3b67fb6f
lib: make overrideable & access via flake
Add a non-system specific `<flake>.lib.nixvim` output, which is
equivalent to the existing `<flake>.lib.<system>.helpers` output.

This is now also wrapped with `lib.makeOverridable` to allow overriding
the function args used to construct the nixvim-lib.

Consistently access nixvim-lib via the new flake output, overriding
where necessary.
2024-12-21 15:17:43 +00:00

52 lines
1.3 KiB
Nix

default_pkgs: self:
{
# TODO: Deprecate this arg in favour of using module options
pkgs ? default_pkgs,
lib ? pkgs.lib,
extraSpecialArgs ? { },
_nixvimTests ? false,
module,
}:
let
# NOTE: we are importing this just for evalNixvim
helpers = self.lib.nixvim.override { inherit _nixvimTests; };
inherit (helpers.modules) evalNixvim;
mkNvim =
mod:
let
nixvimConfig = evalNixvim {
modules = [
mod
# TODO: only include this when `args?pkgs`:
{
_file = ./standalone.nix;
nixpkgs.pkgs = lib.mkDefault pkgs;
}
];
inherit extraSpecialArgs;
};
inherit (nixvimConfig.config) enableMan build;
in
(pkgs.symlinkJoin {
name = "nixvim";
paths = [
build.package
build.printInitPackage
] ++ pkgs.lib.optional enableMan self.packages.${pkgs.stdenv.hostPlatform.system}.man-docs;
meta.mainProgram = "nvim";
})
// rec {
inherit (nixvimConfig) config options;
extend =
extension:
mkNvim {
imports = [
mod
extension
];
};
nixvimExtend = lib.warn "<nixvim>.nixvimExtend has been renamed to <nixvim>.extend" extend;
};
in
mkNvim module