{ pkgs, callModule, ... }: let inherit (builtins) concatLists; inherit (pkgs) bash lib; inherit (lib) concatMap flip literalExample mkEnableOption mkOption mkPackageOption optional optionalString types ; modules = { init = callModule ./init.nix {}; plugin = callModule ./plugin {}; runtime = callModule ./runtime.nix {}; sloth = callModule ./sloth.nix {}; }; extraLuaPackagesType = (with types; functionTo (listOf package)) // { merge = loc: defs: let fnList = map (def: def.value) defs; concatPackages = ps: fn: fn ps; in ps: concatMap (concatPackages ps) fnList; }; mkDiffAlias = name: (flip optionalString) '' cat < $out/bin/${name} #!${bash}/bin/bash exec $out/bin/nvim -d "\''${@}" SH chmod 555 $out/bin/${name} ''; in { defaultModule = { config, lib, ... }: let pkg = pkgs.wrapNeovimUnstable config.package config.neovimOptions; luaRcContent = config.init.finalContent; inherit (config) extraLuaPackages; neovim-unwrapped = config.package; inherit (neovim-unwrapped.lua.pkgs.luaLib) genLuaPathAbsStr genLuaCPathAbsStr; luaEnv = neovim-unwrapped.lua.withPackages extraLuaPackages; neovimOptions = { inherit extraLuaPackages luaRcContent; inherit (config) viAlias vimAlias; wrapRc = luaRcContent != null; plugins = concatLists [ (map modules.plugin.extract config.plugins) (optional (! isNull config.runtime) config.runtime.package) [config.slothPlugin] ]; wrapperArgs = lib.optionals (luaEnv != null) [ "--prefix" "LUA_PATH" ";" (genLuaPathAbsStr luaEnv) "--prefix" "LUA_CPATH" ";" (genLuaCPathAbsStr luaEnv) ]; }; neovimPackage = pkg.overrideAttrs (final: super: { postBuild = super.postBuild + (mkDiffAlias "vimdiff" config.vimdiffAlias) + (mkDiffAlias "nvimdiff" config.nvimdiffAlias); }); in { options = { package = mkPackageOption pkgs "neovim-unwrapped" {}; extraLuaPackages = mkOption { description = '' function to define extra lua packages that should be included in neovim environment. ''; type = extraLuaPackagesType; example = literalExample "p: [p.nvim-nio]"; defaultText = literalExample "_: []"; default = _: []; }; init = modules.init.option; runtime = modules.runtime.option; plugins = modules.plugin.option; viAlias = mkEnableOption "creation on `vi` alias"; vimAlias = mkEnableOption "creation on `vim` alias"; vimdiffAlias = mkEnableOption "creation on `vimdiff` alias"; nvimdiffAlias = mkEnableOption "creation on `nvimdiff` alias"; pluginLuaDefinitions = mkOption { description = '' All lua definitions of plugins. Used by sloth vim plugin ''; type = with types; attrsOf anything; readOnly = true; internal = true; default = modules.sloth.mkPluginLuaDefinitions config.plugins; }; slothPlugin = mkOption { description = '' The resulted sloth plugin ''; type = types.package; readOnly = true; internal = true; default = modules.sloth.mkSlothPlugin config.pluginLuaDefinitions; }; neovimOptions = mkOption { type = types.attrs; readOnly = true; description = "The resulting configuration passed to `pkgs.wrapNeovimUnstable`"; default = neovimOptions; }; neovimPackage = mkOption { type = types.package; description = "The neovim package generated from your configuration."; readOnly = true; # defaultText = lib.literalExpression "pkgs.hello"; default = neovimPackage; }; }; }; }