Compare commits

..

1 commit

Author SHA1 Message Date
09307ec4df
docs: fix build failures doe to literalMD 2024-04-20 19:01:54 +03:00
4 changed files with 44 additions and 67 deletions

View file

@ -7,11 +7,9 @@ inputs: let
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
extraModules ? [],
...
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs extraModules;
inherit pkgs lib check extraSpecialArgs;
configuration.imports = modules;
};

View file

@ -6,8 +6,8 @@ packages: inputs: {
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) optionals;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool;
@ -74,14 +74,16 @@ in {
};
};
config = mkIf cfg.enable {
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
config = mkIf cfg.enable mkMerge [
{
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
packages =
[cfg.finalPackage]
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
};
home = {
sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
packages =
[cfg.finalPackage]
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
}
];
}

View file

@ -6,8 +6,8 @@ packages: inputs: {
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride;
inherit (lib.lists) optional;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) optionals;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool;
@ -74,14 +74,16 @@ in {
};
};
config = mkIf cfg.enable {
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
config = mkIf cfg.enable mkMerge [
{
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
environment = {
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
systemPackages =
[cfg.finalPackage]
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
};
environment = {
variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
systemPackages =
[cfg.finalPackage]
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
}
];
}

View file

@ -4,43 +4,30 @@ inputs: {
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
extraModules ? [],
}: let
inherit (builtins) map filter isString toString getAttr;
inherit (pkgs) wrapNeovimUnstable vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin;
inherit (pkgs.neovimUtils) makeNeovimConfig;
inherit (lib.lists) concatLists;
inherit (lib.attrsets) recursiveUpdate;
inherit (lib.asserts) assertMsg;
# call the extedended library with `lib` and `inputs` as arguments
# lib is used to provide the standard library functions to the extended library
# but it can be overridden while this file is being called
# inputs is used to pass inputs to the plugin autodiscovery function
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
# import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called
# to avoid checking in all modules
nvimModules = import ./modules.nix {
inherit check pkgs;
lib = extendedLib;
};
# evaluate the extended library with the modules
# optionally with any additional modules passed by the user
module = extendedLib.evalModules {
modules = [configuration] ++ nvimModules;
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
modules = concatLists [[configuration] nvimModules extraModules];
};
# alias to the internal configuration
vimOptions = module.config.vim;
# build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
buildPlug = {pname, ...} @ args:
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
buildVimPlugin (args
@ -73,36 +60,24 @@ inputs: {
(f: f != null)
plugins);
# built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: {
plugin = package;
optional = false;
}) (buildConfigPlugins vimOptions.optPlugins);
plugins =
(buildConfigPlugins vimOptions.startPlugins)
++ (map (package: {
plugin = package;
optional = false;
})
(buildConfigPlugins
vimOptions.optPlugins));
plugins = builtStartPlugins ++ builtOptPlugins;
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
# wrap user's desired neovim package using the neovim wrapper from nixpkgs
# the wrapper takes the following arguments:
# - withPython (bool)
# - extraPython3Packages (lambda)
# - withNodeJs (bool)
# - withRuby (bool)
# - extraLuaPackages (lambda)
# - plugins (list)
# - customRC (string)
# and returns the wrapped package
neovim-wrapped = wrapNeovimUnstable vimOptions.package (makeNeovimConfig {
inherit (vimOptions) viAlias vimAlias;
inherit plugins extraLuaPackages;
neovim = wrapNeovimUnstable vimOptions.package (makeNeovimConfig {
inherit (vimOptions) viAlias;
inherit (vimOptions) vimAlias;
inherit extraLuaPackages;
inherit plugins;
customRC = vimOptions.builtConfigRC;
});
in {
inherit (module) options config;
inherit (module._module.args) pkgs;
# expose wrapped neovim-package
neovim = neovim-wrapped;
inherit neovim;
}