mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
Splits everything that depends on a `pkgs` instance into an optional attrs, allowing `helpers.nix` to be bootstrapped without `pkgs`. This required some refactoring: - `modules.specialArgs` is only available when `pkgs` is used - `modules.specialArgsWith` now requires `defaultPkgs` be provided - `builders.*` now have `*With` variants that take `pkgs` as an argument and a `withPkgs` function that returns the old interface - Had to define the fixed part of `builders` outside the attrs for now, to avoid infinite recursion. - The old `builders` are now deprecated, and print a warning when evaluated - `withOptoinalFns` was introduced to merge the optional attrs into the final lib.
29 lines
719 B
Nix
29 lines
719 B
Nix
{
|
|
name,
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
options = {
|
|
plugin = lib.mkOption {
|
|
type = lib.types.package;
|
|
description = "A derivation with the content of the file in it";
|
|
readOnly = true;
|
|
internal = true;
|
|
};
|
|
};
|
|
config =
|
|
let
|
|
derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name;
|
|
writeContent =
|
|
if config.type == "lua" then lib.nixvim.builders.writeLuaWith pkgs else pkgs.writeText;
|
|
in
|
|
{
|
|
path = lib.mkDefault name;
|
|
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
|
|
# No need to use mkDerivedConfig; this option is readOnly.
|
|
plugin = writeContent derivationName config.content;
|
|
};
|
|
}
|