push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
{
lib,
stdenv,
rtpPath,
toVimPlugin,
}:
{
addRtp = drv: lib.warn "`addRtp` is deprecated, does nothing." drv;
buildVimPlugin =
{
name ? "${attrs.pname}-${attrs.version}",
src,
unpackPhase ? "",
configurePhase ? ":",
buildPhase ? ":",
preInstall ? "",
postInstall ? "",
path ? ".",
addonInfo ? null,
meta ? { },
...
}@attrs:
let
drv = stdenv.mkDerivation (
attrs
// {
name = lib.warnIf (attrs ? vimprefix) "The 'vimprefix' is now hardcoded in toVimPlugin" name;
__structuredAttrs = true;
inherit
unpackPhase
configurePhase
buildPhase
addonInfo
preInstall
postInstall
;
installPhase = ''
runHook preInstall
target=$out/${rtpPath}/${path}
mkdir -p $out/${rtpPath}
cp -r . $target
runHook postInstall
'';
meta = {
platforms = lib.platforms.all;
}
// meta;
}
);
in
toVimPlugin drv;
}

View File

@@ -0,0 +1,33 @@
with import <localpkgs> { };
let
inherit (vimUtils.override { inherit vim; }) buildVimPlugin;
inherit (neovimUtils) buildNeovimPlugin;
generated = callPackage <localpkgs/pkgs/applications/editors/vim/plugins/generated.nix> {
inherit buildNeovimPlugin buildVimPlugin;
} { } { };
hasChecksum =
value:
lib.isAttrs value
&& lib.hasAttrByPath [
"src"
"outputHash"
] value;
parse = name: value: {
pname = value.pname;
version = value.version;
homePage = value.meta.homepage;
checksum =
if hasChecksum value then
{
submodules = value.src.fetchSubmodules or false;
sha256 = value.src.outputHash;
rev = value.src.rev;
}
else
null;
};
in
lib.mapAttrs parse generated

View File

@@ -0,0 +1,20 @@
{
pkgs ? import ../../../../../../.. { },
}:
with pkgs;
let
pythonWithPackages = python3.withPackages (
ps: with ps; [
requests
]
);
in
mkShell {
packages = [
nurl
pythonWithPackages
];
}

View File

@@ -0,0 +1,126 @@
#!/usr/bin/env nix-shell
#!nix-shell ./update-shell.nix -i python
import json
import logging
import os
import subprocess
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
import requests
log = logging.getLogger("vim-updater")
NURR_JSON_URL = (
"https://raw.githubusercontent.com/nvim-neorocks/nurr/main/tree-sitter-parsers.json"
)
def generate_grammar(lang, parser_info):
"""Generate grammar for a language based on the parser info"""
if "install_info" not in parser_info:
log.warning(f"Parser {lang} does not have install_info, skipping")
return ""
install_info = parser_info["install_info"]
url = install_info["url"]
rev = install_info["revision"]
generated = f""" {lang} = buildGrammar {{
language = "{lang}";
version = "0.0.0+rev={rev[:7]}";
src = """
generated += subprocess.check_output(
["nurl", url, rev, "--indent=4"], text=True
)
generated += ";"
location = install_info.get("location", "")
if location:
generated += f"""
location = "{location}";"""
if install_info.get("generate", False):
generated += """
generate = true;"""
generated += f"""
meta.homepage = "{url}";
}};
"""
return generated
def fetch_nurr_parsers():
"""Fetch the parser information from nurr repository"""
log.info("Fetching parser data from %s", NURR_JSON_URL)
headers = {}
github_token = os.environ.get("GITHUB_TOKEN")
if github_token:
log.info("Using GITHUB_TOKEN for authentication")
headers["Authorization"] = f"token {github_token}"
else:
log.warning("No GITHUB_TOKEN found. GitHub API requests may be rate-limited.")
response = requests.get(NURR_JSON_URL, headers=headers, timeout=30)
response.raise_for_status()
data = response.json()
try:
parsers = data["parsers"]
except KeyError:
raise ValueError(
"Unexpected response from NURR:\n" + json.dumps(data, indent=2)
)
log.info(f"Successfully fetched {len(parsers)} parsers")
return parsers
def process_parser_info(parser_info):
"""Process a single parser info entry and generate grammar for it"""
return generate_grammar(parser_info["lang"], parser_info)
def update_grammars():
"""Update grammar definitions using nurr's parser information"""
parsers_info = fetch_nurr_parsers()
generated_file = """# generated by pkgs/applications/editors/vim/plugins/utils/nvim-treesitter/update.py
# Using parser data from https://github.com/nvim-neorocks/nurr/blob/main/tree-sitter-parsers.json
{
buildGrammar,
"""
nurl_output = subprocess.check_output(["nurl", "-Ls", ","], text=True).strip()
indented_output = nurl_output.replace(",", ",\n ")
generated_file += indented_output
generated_file += """,
}:
{
"""
# Process parsers in parallel for better performance
with ThreadPoolExecutor(max_workers=5) as executor:
for generated in executor.map(process_parser_info, parsers_info):
generated_file += generated
generated_file += "}\n"
return generated_file
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
generated = update_grammars()
output_path = Path(__file__).parent.parent.parent / "nvim-treesitter/generated.nix"
log.info("Writing output to %s", output_path)
with open(output_path, "w") as f:
f.write(generated)
log.info("Successfully updated grammar definitions")

View File

@@ -0,0 +1,170 @@
#!/usr/bin/env python
# run with:
# $ nix run .\#vimPluginsUpdater
# format:
# $ nix run nixpkgs#python3Packages.ruff -- update.py
# type-check:
# $ nix run nixpkgs#python3Packages.mypy -- update.py
# linted:
# $ nix run nixpkgs#python3Packages.flake8 -- --ignore E501,E265,E402 update.py
# If you see `HTTP Error 429: too many requests` errors while running this
# script, refer to:
#
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md#updating-plugins-in-nixpkgs-updating-plugins-in-nixpkgs
#
# (or the equivalent file /doc/languages-frameworks/vim.section.md
# from Nixpkgs master tree).
#
import inspect
import logging
import os
import textwrap
from pathlib import Path
from typing import List, Tuple
log = logging.getLogger("vim-updater")
# Import plugin update library from maintainers/scripts/pluginupdate.py
ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
import importlib
import pluginupdate
from pluginupdate import PluginDesc, run_nix_expr
treesitter = importlib.import_module("nvim-treesitter.update")
HEADER = (
"# GENERATED by ./pkgs/applications/editors/vim/plugins/utils/update.py. Do not edit!"
)
NIXPKGS_NVIMTREESITTER_FOLDER = "pkgs/applications/editors/vim/plugins/nvim-treesitter"
class VimEditor(pluginupdate.Editor):
nvim_treesitter_updated = False
def generate_nix(
self, plugins: List[Tuple[PluginDesc, pluginupdate.Plugin]], outfile: str
):
log.info("Generating nix code")
log.debug("Loading nvim-treesitter revision from nix...")
nvim_treesitter_rev = pluginupdate.run_nix_expr(
"(import <localpkgs> { }).vimPlugins.nvim-treesitter.src.rev",
self.nixpkgs,
timeout=10,
)
GET_PLUGINS_LUA = """
with import <localpkgs> {};
lib.attrNames lua51Packages"""
log.debug("Loading list of lua plugins...")
luaPlugins = run_nix_expr(GET_PLUGINS_LUA, self.nixpkgs, timeout=30)
def _isNeovimPlugin(plug: pluginupdate.Plugin) -> bool:
"""
Whether it's a neovim-only plugin
We can check if it's available in lua packages
"""
if plug.normalized_name in luaPlugins:
log.debug("%s is a neovim plugin", plug)
return True
return False
with open(outfile, "w+") as f:
log.debug("Writing to %s", outfile)
f.write(HEADER)
f.write(
textwrap.dedent(
"""
{
lib,
buildVimPlugin,
buildNeovimPlugin,
fetchFromGitHub,
}:
final: prev: {
"""
)
)
for pdesc, plugin in plugins:
content = self.plugin2nix(pdesc, plugin, _isNeovimPlugin(plugin))
f.write(content)
if (
plugin.name == "nvim-treesitter"
and plugin.commit != nvim_treesitter_rev
):
self.nvim_treesitter_updated = True
f.write("}\n")
print(f"updated {outfile}")
def plugin2nix(
self, pdesc: PluginDesc, plugin: pluginupdate.Plugin, isNeovim: bool
) -> str:
if isNeovim:
raise RuntimeError(f"Plugin {plugin.name} is already packaged in `luaPackages`, please use that")
repo = pdesc.repo
content = f" {plugin.normalized_name} = "
src_nix = repo.as_nix(plugin)
content += """{buildFn} {{
pname = "{plugin.name}";
version = "{plugin.version}";
src = {src_nix};
meta.homepage = "{repo.uri}";
meta.hydraPlatforms = [ ];
}};
""".format(
buildFn="buildNeovimPlugin" if isNeovim else "buildVimPlugin",
plugin=plugin,
src_nix=src_nix,
repo=repo,
)
log.debug(content)
return content
def update(self, args):
pluginupdate.update_plugins(self, args)
# TODO this should probably be skipped when running outside a nixpkgs checkout
if self.nvim_treesitter_updated:
print("updating nvim-treesitter grammars")
generated = treesitter.update_grammars()
treesitter_generated_nix_path = os.path.join(
NIXPKGS_NVIMTREESITTER_FOLDER, "generated.nix"
)
open(os.path.join(args.nixpkgs, treesitter_generated_nix_path), "w").write(
generated
)
if self.nixpkgs_repo:
index = self.nixpkgs_repo.index
for diff in index.diff(None):
if diff.a_path == treesitter_generated_nix_path:
msg = "vimPlugins.nvim-treesitter: update grammars"
print(f"committing to nixpkgs: {msg}")
index.add([treesitter_generated_nix_path])
index.commit(msg)
return
print("no updates to nvim-treesitter grammars")
def main():
global luaPlugins
log.debug(f"Loading from {ROOT}/get-plugins.nix")
with open(f"{ROOT}/get-plugins.nix") as f:
GET_PLUGINS = f.read()
editor = VimEditor(
"vim", Path("pkgs/applications/editors/vim/plugins"), GET_PLUGINS
)
editor.run()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,60 @@
{
lib,
buildPythonApplication,
makeWrapper,
nix,
nix-prefetch-git,
nurl,
python3Packages,
vimPluginsUpdater,
writeShellScript,
# optional
neovim-unwrapped,
}:
buildPythonApplication {
pname = "vim-plugins-updater";
version = "0.1";
format = "other";
nativeBuildInputs = [
makeWrapper
python3Packages.wrapPython
];
pythonPath = [
python3Packages.gitpython
python3Packages.requests
];
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin $out/lib
cp ${./update.py} $out/bin/vim-plugins-updater
cp ${./get-plugins.nix} $out/bin/get-plugins.nix
# wrap python scripts
makeWrapperArgs+=( --prefix PATH : "${
lib.makeBinPath [
nix
nix-prefetch-git
neovim-unwrapped
nurl
]
}" --prefix PYTHONPATH : "${./.}:${../../../../../../maintainers/scripts/pluginupdate-py}" )
wrapPythonPrograms
'';
shellHook = ''
export PYTHONPATH=pkgs/applications/editors/vim/plugins:maintainers/scripts/pluginupdate-py:$PYTHONPATH
'';
passthru.updateScript = writeShellScript "updateScript" ''
# don't saturate the update bot connection
${lib.getExe vimPluginsUpdater} --proc 2 update
'';
meta.mainProgram = "vim-plugins-updater";
}

View File

@@ -0,0 +1,520 @@
# tests available at pkgs/test/vim
{
lib,
stdenv,
vim,
vimPlugins,
buildEnv,
writeText,
runCommand,
makeWrapper,
python3,
callPackage,
makeSetupHook,
linkFarm,
config,
}:
/*
USAGE EXAMPLE
=============
Install Vim like this eg using nixos option environment.systemPackages which will provide
vim-with-plugins in PATH:
vim-full.customize {
name = "vim-with-plugins"; # optional
# add custom .vimrc lines like this:
vimrcConfig.customRC = ''
set hidden
'';
# store your plugins in Vim packages
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
# loaded on launch
start = [ youcompleteme fugitive ];
# manually loadable by calling `:packadd $plugin-name`
opt = [ phpCompletion elm-vim ];
# To automatically load a plugin when opening a filetype, add vimrc lines like:
# autocmd FileType php :packadd phpCompletion
};
};
WHAT IS A VIM PLUGIN?
=====================
Typical plugin files:
plugin/P1.vim
autoload/P1.vim
ftplugin/xyz.vim
doc/plugin-documentation.txt (traditional documentation)
README(.md) (nowadays thanks to github)
Vim offers the :h rtp setting which works for most plugins. Thus adding
this to your .vimrc should make most plugins work:
set rtp+=~/.nix-profile/share/vim-plugins/youcompleteme
" or for p in ["youcompleteme"] | exec 'set rtp+=~/.nix-profile/share/vim-plugins/'.p | endfor
Learn about about plugin Vim plugin mm managers at
http://vim-wiki.mawercer.de/wiki/topic/vim%20plugin%20managment.html.
The documentation can be accessed by Vim's :help command if it was tagged.
See vimHelpTags sample code below.
CONTRIBUTING AND CUSTOMIZING
============================
The example file pkgs/applications/editors/vim/plugins/default.nix provides
both:
* manually maintained plugins
* plugins created by VAM's nix#ExportPluginsForNix implementation
I highly recommend to lookup vim plugin attribute names at the [vim-pi] project
which is a database containing all plugins from
vim.org and quite a lot of found at github and similar sources. vim-pi's documented purpose
is to associate vim.org script ids to human readable names so that dependencies
can be describe easily.
How to find a name?
* http://vam.mawercer.de/ or VAM's
* grep vim-pi
* use VAM's completion or :AddonsInfo command
It might happen than a plugin is not known by vim-pi yet. We encourage you to
contribute to vim-pi so that plugins can be updated automatically.
CREATING DERIVATIONS AUTOMATICALLY BY PLUGIN NAME
==================================================
Most convenient is to use a ~/.vim-scripts file putting a plugin name into each line
as documented by [VAM]'s README.md
It is the same format you pass to vimrcConfig.vam.pluginDictionaries from the
usage example above.
Then create a temp vim file and insert:
let opts = {}
let opts.path_to_nixpkgs = '/etc/nixos/nixpkgs'
let opts.cache_file = '/tmp/export-vim-plugin-for-nix-cache-file'
let opts.plugin_dictionaries = map(readfile("vim-plugins"), 'eval(v:val)')
" add more files
" let opts.plugin_dictionaries += map(.. other file )
call nix#ExportPluginsForNix(opts)
Then ":source %" it.
nix#ExportPluginsForNix is provided by ./vim2nix
A buffer will open containing the plugin derivation lines as well list
fitting the vimrcConfig.vam.pluginDictionaries option.
Thus the most simple usage would be:
vim_with_plugins =
let vim = vim-full;
inherit (vimUtil.override {inherit vim}) rtpPath addRtp buildVimPlugin vimHelpTags;
vimPlugins = [
# the derivation list from the buffer created by nix#ExportPluginsForNix
# don't set which will default to pkgs.vimPlugins
];
in vim.customize {
name = "vim-with-plugins";
vimrcConfig.customRC = '' .. '';
vimrcConfig.vam.knownPlugins = vimPlugins;
vimrcConfig.vam.pluginDictionaries = [
# the plugin list form ~/.vim-scripts turned into nix format added to
# the buffer created by the nix#ExportPluginsForNix
];
}
vim_with_plugins can be installed like any other application within Nix.
[VAM] https://github.com/MarcWeber/vim-addon-manager
[vim-pi] https://bitbucket.org/vimcommunity/vim-pi
*/
let
inherit lib;
# make sure a plugin is a derivation and its dependencies are derivations. If
# plugin already is a derivation, this is a no-op. If it is a string, it is
# looked up in knownPlugins.
pluginToDrv =
knownPlugins: plugin:
let
drv =
if builtins.isString plugin then
# make sure `pname` is set to that we are able to convert the derivation
# back to a string.
(knownPlugins.${plugin} // { pname = plugin; })
else
plugin;
in
# make sure all the dependencies of the plugin are also derivations
drv // { dependencies = map (pluginToDrv knownPlugins) (drv.dependencies or [ ]); };
# transitive closure of plugin dependencies (plugin needs to be a derivation)
transitiveClosure =
plugin:
[ plugin ]
++ (lib.unique (builtins.concatLists (map transitiveClosure plugin.dependencies or [ ])));
findDependenciesRecursively = plugins: lib.concatMap transitiveClosure plugins;
vamDictToNames =
x: if builtins.isString x then [ x ] else (lib.optional (x ? name) x.name) ++ (x.names or [ ]);
rtpPath = ".";
vimFarm =
prefix: name: drvs:
let
mkEntryFromDrv = drv: {
name = "${prefix}/${lib.getName drv}";
path = drv;
};
in
linkFarm name (map mkEntryFromDrv drvs);
/*
Generates a packpath folder as expected by vim
Example:
packDir (myVimPackage.{ start = [ vimPlugins.vim-fugitive ]; opt = [] })
=> "/nix/store/xxxxx-pack-dir"
*/
packDir =
packages:
let
packageLinks =
packageName:
{
start ? [ ],
opt ? [ ],
}:
let
# `nativeImpl` expects packages to be derivations, not strings (as
# opposed to older implementations that have to maintain backwards
# compatibility). Therefore we don't need to deal with "knownPlugins"
# and can simply pass `null`.
depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively opt);
startWithDeps = findDependenciesRecursively start;
allPlugins = lib.unique (startWithDeps ++ depsOfOptionalPlugins);
allPython3Dependencies =
ps: lib.flatten (map (plugin: (plugin.python3Dependencies or (_: [ ])) ps) allPlugins);
python3Env = python3.withPackages allPython3Dependencies;
packdirStart = vimFarm "pack/${packageName}/start" "packdir-start" allPlugins;
packdirOpt = vimFarm "pack/${packageName}/opt" "packdir-opt" opt;
# Assemble all python3 dependencies into a single `site-packages` to avoid doing recursive dependency collection
# for each plugin.
# This directory is only for python import search path, and will not slow down the startup time.
# see :help python3-directory for more details
python3link = runCommand "vim-python3-deps" { } ''
mkdir -p $out/pack/${packageName}/start/__python3_dependencies
ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3
'';
in
[
packdirStart
packdirOpt
]
++ lib.optional (allPython3Dependencies python3.pkgs != [ ]) python3link;
in
buildEnv {
name = "vim-pack-dir";
paths = (lib.flatten (lib.mapAttrsToList packageLinks packages));
};
nativeImpl = packages: ''
set packpath^=${packDir packages}
set runtimepath^=${packDir packages}
'';
/*
Generates a vimrc string
packages is an attrset with {name: { start = [ vim derivations ]; opt = [ vim derivations ]; }
Example:
vimrcContent {
packages = { home-manager = { start = [vimPlugins.vim-fugitive]; opt = [];};
beforePlugins = '';
customRC = ''let mapleader = " "'';
};
*/
vimrcContent =
{
packages ? null,
vam ? null, # deprecated
pathogen ? null, # deprecated
plug ? null,
beforePlugins ? ''
" configuration generated by NIX
set nocompatible
'',
customRC ? null,
}:
let
# vim-plug is an extremely popular vim plugin manager.
plugImpl = ''
source ${vimPlugins.vim-plug}/plug.vim
silent! call plug#begin('/dev/null')
''
+ (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg}'") plug.plugins)
+ ''
call plug#end()
'';
# vim-addon-manager = VAM (deprecated)
vamImpl =
let
knownPlugins = vam.knownPlugins or vimPlugins;
# plugins specified by the user
specifiedPlugins = map (pluginToDrv knownPlugins) (
lib.concatMap vamDictToNames vam.pluginDictionaries
);
# plugins with dependencies
plugins = findDependenciesRecursively specifiedPlugins;
vamPackages.vam = {
start = plugins;
};
in
nativeImpl vamPackages;
entries = [
beforePlugins
]
++ lib.optional (vam != null) (
lib.warn "'vam' attribute is deprecated. Use 'packages' instead in your vim configuration" vamImpl
)
++ lib.optional (packages != null && packages != [ ]) (nativeImpl packages)
++ lib.optional (pathogen != null) (
throw "pathogen is now unsupported, replace `pathogen = {}` with `packages.home = { start = []; }`"
)
++ lib.optional (plug != null) plugImpl
++ [ customRC ];
in
lib.concatStringsSep "\n" (lib.filter (x: x != null && x != "") entries);
vimrcFile = settings: writeText "vimrc" (vimrcContent settings);
in
rec {
inherit vimrcFile;
inherit vimrcContent;
inherit packDir;
makeCustomizable =
let
mkVimrcFile = vimrcFile; # avoid conflict with argument name
in
vim:
vim
// {
# Returns a customized vim that uses the specified vimrc configuration.
customize =
{
# The name of the derivation.
name ? "vim",
# A shell word used to specify the names of the customized executables.
# The shell variable $exe can be used to refer to the wrapped executable's name.
# Examples: "my-$exe", "$exe-with-plugins", "\${exe/vim/v1m}"
executableName ?
if lib.hasInfix "vim" name then
lib.replaceStrings [ "vim" ] [ "$exe" ] name
else
"\${exe/vim/${lib.escapeShellArg name}}",
# A custom vimrc configuration, treated as an argument to vimrcContent (see the documentation in this file).
vimrcConfig ? null,
# A custom vimrc file.
vimrcFile ? null,
# A custom gvimrc file.
gvimrcFile ? null,
# If set to true, return the *vim wrappers only.
# If set to false, overlay the wrappers on top of the original vim derivation.
# This ensures that things like man pages and .desktop files are available.
standalone ? name != "vim" && wrapManual != true,
# deprecated arguments (TODO: remove eventually)
wrapManual ? null,
wrapGui ? null,
vimExecutableName ? null,
gvimExecutableName ? null,
}:
lib.warnIf (wrapManual != null)
''
vim.customize: wrapManual is deprecated: the manual is now included by default if `name == "vim"`.
${
if wrapManual == true && name != "vim" then
"Set `standalone = false` to include the manual."
else
lib.optionalString (
wrapManual == false && name == "vim"
) "Set `standalone = true` to get the *vim wrappers only."
}''
lib.warnIf
(wrapGui != null)
"vim.customize: wrapGui is deprecated: gvim is now automatically included if present"
lib.throwIfNot
(vimExecutableName == null && gvimExecutableName == null)
"vim.customize: (g)vimExecutableName is deprecated: use executableName instead (see source code for examples)"
(
let
vimrc =
if vimrcFile != null then
vimrcFile
else if vimrcConfig != null then
mkVimrcFile vimrcConfig
else
throw "at least one of vimrcConfig and vimrcFile must be specified";
bin = runCommand "${name}-bin" { nativeBuildInputs = [ makeWrapper ]; } ''
vimrc=${lib.escapeShellArg vimrc}
gvimrc=${lib.optionalString (gvimrcFile != null) (lib.escapeShellArg gvimrcFile)}
mkdir -p "$out/bin"
for exe in ${
if standalone then "{,g,r,rg,e}vim {,g}vimdiff vi" else "{,g,r,rg,e}{vim,view} {,g}vimdiff ex vi"
}; do
if [[ -e ${vim}/bin/$exe ]]; then
dest="$out/bin/${executableName}"
if [[ -e $dest ]]; then
echo "ambiguous executableName: ''${dest##*/} already exists"
continue
fi
makeWrapper ${vim}/bin/"$exe" "$dest" \
--add-flags "-u ''${vimrc@Q} ''${gvimrc:+-U ''${gvimrc@Q}}"
fi
done
'';
in
if standalone then
bin
else
buildEnv {
inherit name;
paths = [
(lib.lowPrio vim)
bin
];
}
);
override = f: makeCustomizable (vim.override f);
overrideAttrs = f: makeCustomizable (vim.overrideAttrs f);
};
vimGenDocHook = callPackage (
{ vim }:
makeSetupHook {
name = "vim-gen-doc-hook";
propagatedBuildInputs = [ vim ];
substitutions = {
vimBinary = "${vim}/bin/vim";
inherit rtpPath;
};
} ../hooks/vim-gen-doc-hook.sh
) { };
vimCommandCheckHook = callPackage (
{ neovim-unwrapped }:
makeSetupHook {
name = "vim-command-check-hook";
propagatedBuildInputs = [ neovim-unwrapped ];
substitutions = {
vimBinary = "${neovim-unwrapped}/bin/nvim";
inherit rtpPath;
};
} ../hooks/vim-command-check-hook.sh
) { };
neovimRequireCheckHook = callPackage (
{ neovim-unwrapped }:
makeSetupHook {
name = "neovim-require-check-hook";
propagatedBuildInputs = [ neovim-unwrapped ];
substitutions = {
nvimBinary = "${neovim-unwrapped}/bin/nvim";
inherit rtpPath;
};
} ../hooks/neovim-require-check-hook.sh
) { };
inherit
(import ./build-vim-plugin.nix {
inherit
lib
stdenv
rtpPath
toVimPlugin
;
})
buildVimPlugin
;
buildVimPluginFrom2Nix = lib.warn "buildVimPluginFrom2Nix is deprecated: use buildVimPlugin instead" buildVimPlugin;
# used to figure out which python dependencies etc. neovim needs
requiredPlugins =
{
packages ? { },
plug ? null,
...
}:
let
nativePluginsConfigs = lib.attrsets.attrValues packages;
nonNativePlugins = (lib.optionals (plug != null) plug.plugins);
nativePlugins = lib.concatMap requiredPluginsForPackage nativePluginsConfigs;
in
nativePlugins ++ nonNativePlugins;
# figures out which python dependencies etc. is needed for one vim package
requiredPluginsForPackage =
{
start ? [ ],
opt ? [ ],
}:
start ++ opt;
toVimPlugin =
drv:
drv.overrideAttrs (oldAttrs: {
name = "vimplugin-${oldAttrs.name}";
# dont move the "doc" folder since vim expects it
forceShare = [
"man"
"info"
];
nativeBuildInputs =
oldAttrs.nativeBuildInputs or [ ]
++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
vimGenDocHook
];
doCheck = oldAttrs.doCheck or true;
nativeCheckInputs =
oldAttrs.nativeCheckInputs or [ ]
++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
vimCommandCheckHook
# many neovim plugins keep using buildVimPlugin
neovimRequireCheckHook
];
passthru = (oldAttrs.passthru or { }) // {
vimPlugin = true;
};
});
}
// lib.optionalAttrs config.allowAliases {
vimWithRC = throw "vimWithRC was removed, please use vim.customize instead";
}