uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
143
pkgs/applications/editors/vim/plugins/aliases.nix
Normal file
143
pkgs/applications/editors/vim/plugins/aliases.nix
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
# Deprecated aliases - for backward compatibility
|
||||
lib:
|
||||
|
||||
final: prev:
|
||||
|
||||
let
|
||||
# Removing recurseForDerivation prevents derivations of aliased attribute
|
||||
# set to appear while listing all the packages available.
|
||||
removeRecurseForDerivations = alias: with lib;
|
||||
if alias.recurseForDerivations or false then
|
||||
removeAttrs alias ["recurseForDerivations"]
|
||||
else alias;
|
||||
|
||||
# Disabling distribution prevents top-level aliases for non-recursed package
|
||||
# sets from building on Hydra.
|
||||
removeDistribute = alias: with lib;
|
||||
if isDerivation alias then
|
||||
dontDistribute alias
|
||||
else alias;
|
||||
|
||||
# Make sure that we are not shadowing something from
|
||||
# all-packages.nix.
|
||||
checkInPkgs = n: alias: if builtins.hasAttr n prev
|
||||
then throw "Alias ${n} is still in vim-plugins"
|
||||
else alias;
|
||||
|
||||
mapAliases = aliases:
|
||||
lib.mapAttrs (n: alias: removeDistribute
|
||||
(removeRecurseForDerivations
|
||||
(checkInPkgs n alias)))
|
||||
aliases;
|
||||
|
||||
deprecations = lib.mapAttrs (old: info:
|
||||
throw "${old} was renamed to ${info.new} on ${info.date}. Please update to ${info.new}."
|
||||
) (lib.importJSON ./deprecated.json);
|
||||
|
||||
in
|
||||
mapAliases (with prev; {
|
||||
airline = vim-airline;
|
||||
alternative = a-vim; # backwards compat, added 2014-10-21
|
||||
bats = bats-vim;
|
||||
BufOnly = BufOnly-vim;
|
||||
calendar = calendar-vim;
|
||||
coffee-script = vim-coffee-script;
|
||||
coffeeScript = vim-coffee-script; # backwards compat, added 2014-10-18
|
||||
Solarized = vim-colors-solarized;
|
||||
solarized = vim-colors-solarized;
|
||||
colors-solarized = vim-colors-solarized;
|
||||
caw = caw-vim;
|
||||
colorsamplerpack = Colour-Sampler-Pack;
|
||||
Colour_Sampler_Pack = Colour-Sampler-Pack;
|
||||
command_T = command-t; # backwards compat, added 2014-10-18
|
||||
commentary = vim-commentary;
|
||||
committia = committia-vim;
|
||||
concealedyank = concealedyank-vim;
|
||||
context-filetype = context_filetype-vim;
|
||||
Cosco = cosco-vim;
|
||||
css_color_5056 = vim-css-color;
|
||||
CSApprox = csapprox;
|
||||
csv = csv-vim;
|
||||
ctrlp = ctrlp-vim;
|
||||
cute-python = vim-cute-python;
|
||||
denite = denite-nvim;
|
||||
easy-align = vim-easy-align;
|
||||
easygit = vim-easygit;
|
||||
easymotion = vim-easymotion;
|
||||
echodoc = echodoc-vim;
|
||||
eighties = vim-eighties;
|
||||
extradite = vim-extradite;
|
||||
fugitive = vim-fugitive;
|
||||
ghc-mod-vim = ghcmod-vim;
|
||||
ghcmod = ghcmod-vim;
|
||||
goyo = goyo-vim;
|
||||
Gist = vim-gist;
|
||||
gitgutter = vim-gitgutter;
|
||||
gundo = gundo-vim;
|
||||
Gundo = gundo-vim; # backwards compat, added 2015-10-03
|
||||
haskellConceal = vim-haskellconceal; # backwards compat, added 2014-10-18
|
||||
haskellConcealPlus = vim-haskellConcealPlus;
|
||||
haskellconceal = vim-haskellconceal;
|
||||
hier = vim-hier;
|
||||
hlint-refactor = hlint-refactor-vim;
|
||||
hoogle = vim-hoogle;
|
||||
Hoogle = vim-hoogle;
|
||||
indent-blankline-nvim-lua = indent-blankline-nvim; # backwards compat, added 2021-07-05
|
||||
ipython = vim-ipython;
|
||||
latex-live-preview = vim-latex-live-preview;
|
||||
maktaba = vim-maktaba;
|
||||
multiple-cursors = vim-multiple-cursors;
|
||||
necoGhc = neco-ghc; # backwards compat, added 2014-10-18
|
||||
neocomplete = neocomplete-vim;
|
||||
neoinclude = neoinclude-vim;
|
||||
neomru = neomru-vim;
|
||||
neosnippet = neosnippet-vim;
|
||||
The_NERD_Commenter = nerdcommenter;
|
||||
The_NERD_tree = nerdtree;
|
||||
open-browser = open-browser-vim;
|
||||
pathogen = vim-pathogen;
|
||||
polyglot = vim-polyglot;
|
||||
prettyprint = vim-prettyprint;
|
||||
quickrun = vim-quickrun;
|
||||
rainbow_parentheses = rainbow_parentheses-vim;
|
||||
repeat = vim-repeat;
|
||||
riv = riv-vim;
|
||||
rhubarb = vim-rhubarb;
|
||||
sensible = vim-sensible;
|
||||
signature = vim-signature;
|
||||
snipmate = vim-snipmate;
|
||||
sourcemap = sourcemap-vim;
|
||||
"sourcemap.vim" = sourcemap-vim;
|
||||
surround = vim-surround;
|
||||
sleuth = vim-sleuth;
|
||||
solidity = vim-solidity;
|
||||
stylish-haskell = vim-stylish-haskell;
|
||||
stylishHaskell = vim-stylish-haskell; # backwards compat, added 2014-10-18
|
||||
Supertab = supertab;
|
||||
Syntastic = syntastic;
|
||||
SyntaxRange = vim-SyntaxRange;
|
||||
table-mode = vim-table-mode;
|
||||
taglist = taglist-vim;
|
||||
tabpagebuffer = tabpagebuffer-vim;
|
||||
tabpagecd = vim-tabpagecd;
|
||||
Tabular = tabular;
|
||||
Tagbar = tagbar;
|
||||
thumbnail = thumbnail-vim;
|
||||
tlib = tlib_vim;
|
||||
tmux-navigator = vim-tmux-navigator;
|
||||
tmuxNavigator = vim-tmux-navigator; # backwards compat, added 2014-10-18
|
||||
tslime = tslime-vim;
|
||||
unite = unite-vim;
|
||||
UltiSnips = ultisnips;
|
||||
vim-addon-vim2nix = vim2nix;
|
||||
vimproc = vimproc-vim;
|
||||
vimshell = vimshell-vim;
|
||||
vinegar = vim-vinegar;
|
||||
watchdogs = vim-watchdogs;
|
||||
WebAPI = webapi-vim;
|
||||
wombat256 = wombat256-vim; # backwards compat, added 2015-7-8
|
||||
yankring = YankRing-vim;
|
||||
Yankring = YankRing-vim;
|
||||
xterm-color-table = xterm-color-table-vim;
|
||||
zeavim = zeavim-vim;
|
||||
} // deprecations)
|
||||
52
pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
Normal file
52
pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{ lib, stdenv
|
||||
, rtpPath
|
||||
, vim
|
||||
, vimCommandCheckHook
|
||||
, vimGenDocHook
|
||||
, neovimRequireCheckHook
|
||||
}:
|
||||
|
||||
rec {
|
||||
buildVimPlugin = attrs@{
|
||||
name ? "${attrs.pname}-${attrs.version}",
|
||||
namePrefix ? "vimplugin-",
|
||||
src,
|
||||
unpackPhase ? "",
|
||||
configurePhase ? "",
|
||||
buildPhase ? "",
|
||||
preInstall ? "",
|
||||
postInstall ? "",
|
||||
path ? ".",
|
||||
addonInfo ? null,
|
||||
...
|
||||
}:
|
||||
let drv = stdenv.mkDerivation (attrs // {
|
||||
name = namePrefix + name;
|
||||
|
||||
# dont move the doc folder since vim expects it
|
||||
forceShare= [ "man" "info" ];
|
||||
|
||||
nativeBuildInputs = attrs.nativeBuildInputs or []
|
||||
++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ vimCommandCheckHook vimGenDocHook ];
|
||||
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
target=$out/${rtpPath}/${path}
|
||||
mkdir -p $out/${rtpPath}
|
||||
cp -r . $target
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
});
|
||||
in drv.overrideAttrs(oa: {
|
||||
rtp = "${drv}";
|
||||
});
|
||||
|
||||
buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
|
||||
# vim plugins may override this
|
||||
buildPhase = ":";
|
||||
configurePhase =":";
|
||||
} // attrs);
|
||||
}
|
||||
52
pkgs/applications/editors/vim/plugins/default.nix
Normal file
52
pkgs/applications/editors/vim/plugins/default.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# TODO check that no license information gets lost
|
||||
{ callPackage, config, lib, vimUtils, vim, darwin, llvmPackages, luaPackages }:
|
||||
|
||||
let
|
||||
|
||||
inherit (vimUtils.override {inherit vim;})
|
||||
buildVimPluginFrom2Nix vimGenDocHook vimCommandCheckHook;
|
||||
|
||||
inherit (lib) extends;
|
||||
|
||||
initialPackages = self: {
|
||||
# Convert derivation to a vim plugin.
|
||||
toVimPlugin = drv:
|
||||
drv.overrideAttrs(oldAttrs: {
|
||||
|
||||
nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [
|
||||
vimGenDocHook
|
||||
vimCommandCheckHook
|
||||
];
|
||||
passthru = (oldAttrs.passthru or {}) // {
|
||||
vimPlugin = true;
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
plugins = callPackage ./generated.nix {
|
||||
inherit buildVimPluginFrom2Nix;
|
||||
inherit (vimUtils) buildNeovimPluginFrom2Nix;
|
||||
};
|
||||
|
||||
# TL;DR
|
||||
# * Add your plugin to ./vim-plugin-names
|
||||
# * run ./update.py
|
||||
#
|
||||
# If additional modifications to the build process are required,
|
||||
# add to ./overrides.nix.
|
||||
overrides = callPackage ./overrides.nix {
|
||||
inherit (darwin.apple_sdk.frameworks) Cocoa CoreFoundation CoreServices;
|
||||
inherit buildVimPluginFrom2Nix;
|
||||
inherit llvmPackages luaPackages;
|
||||
};
|
||||
|
||||
aliases = if config.allowAliases then (import ./aliases.nix lib) else final: prev: {};
|
||||
|
||||
extensible-self = lib.makeExtensible
|
||||
(extends aliases
|
||||
(extends overrides
|
||||
(extends plugins initialPackages)
|
||||
)
|
||||
);
|
||||
in
|
||||
extensible-self
|
||||
42
pkgs/applications/editors/vim/plugins/deprecated.json
Normal file
42
pkgs/applications/editors/vim/plugins/deprecated.json
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"compe-tmux": {
|
||||
"date": "2021-12-21",
|
||||
"new": "cmp-tmux"
|
||||
},
|
||||
"gist-vim": {
|
||||
"date": "2020-03-27",
|
||||
"new": "vim-gist"
|
||||
},
|
||||
"nvim-bufferline-lua": {
|
||||
"date": "2021-08-22",
|
||||
"new": "bufferline-nvim"
|
||||
},
|
||||
"nvim-lsp": {
|
||||
"date": "2020-08-31",
|
||||
"new": "nvim-lspconfig"
|
||||
},
|
||||
"nvim-toggleterm-lua": {
|
||||
"date": "2021-08-22",
|
||||
"new": "toggleterm-nvim"
|
||||
},
|
||||
"orgmode-nvim": {
|
||||
"date": "2021-11-28",
|
||||
"new": "orgmode"
|
||||
},
|
||||
"sql-nvim": {
|
||||
"date": "2021-09-03",
|
||||
"new": "sqlite-lua"
|
||||
},
|
||||
"vim-jade": {
|
||||
"date": "2020-03-27",
|
||||
"new": "vim-pug"
|
||||
},
|
||||
"vundle": {
|
||||
"date": "2020-03-27",
|
||||
"new": "Vundle-vim"
|
||||
},
|
||||
"youcompleteme": {
|
||||
"date": "2020-03-27",
|
||||
"new": "YouCompleteMe"
|
||||
}
|
||||
}
|
||||
12388
pkgs/applications/editors/vim/plugins/generated.nix
Normal file
12388
pkgs/applications/editors/vim/plugins/generated.nix
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,31 @@
|
|||
diff --git a/autoload/health/mkdp.vim b/autoload/health/mkdp.vim
|
||||
index 9eebb56..3a0b069 100644
|
||||
--- a/autoload/health/mkdp.vim
|
||||
+++ b/autoload/health/mkdp.vim
|
||||
@@ -9,8 +9,8 @@ function! health#mkdp#check() abort
|
||||
call health#report_info('Pre build: ' . l:mkdp_server_script)
|
||||
call health#report_info('Pre build version: ' . mkdp#util#pre_build_version())
|
||||
call health#report_ok('Using pre build')
|
||||
- elseif executable('node')
|
||||
- call health#report_info('Node version: ' . system('node --version'))
|
||||
+ else
|
||||
+ call health#report_info('Node version: ' . system('@node@ --version'))
|
||||
let l:mkdp_server_script = s:mkdp_root_dir . '/app/server.js'
|
||||
call health#report_info('Script: ' . l:mkdp_server_script)
|
||||
call health#report_info('Script exists: ' . filereadable(l:mkdp_server_script))
|
||||
diff --git a/autoload/mkdp/rpc.vim b/autoload/mkdp/rpc.vim
|
||||
index b257571..57f04e7 100644
|
||||
--- a/autoload/mkdp/rpc.vim
|
||||
+++ b/autoload/mkdp/rpc.vim
|
||||
@@ -41,9 +41,9 @@ function! mkdp#rpc#start_server() abort
|
||||
let l:mkdp_server_script = s:mkdp_root_dir . '/app/bin/markdown-preview-' . mkdp#util#get_platform()
|
||||
if executable(l:mkdp_server_script)
|
||||
let l:cmd = [l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
|
||||
- elseif executable('node')
|
||||
+ else
|
||||
let l:mkdp_server_script = s:mkdp_root_dir . '/app/index.js'
|
||||
- let l:cmd = ['node', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
|
||||
+ let l:cmd = ['@node@', l:mkdp_server_script, '--path', s:mkdp_root_dir . '/app/server.js']
|
||||
endif
|
||||
if exists('l:cmd')
|
||||
if s:is_vim
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "markdown-preview-vim",
|
||||
"version": "0.0.1",
|
||||
"description": "markdown preview plugin for (neo)vim",
|
||||
"bin": "./index.js",
|
||||
"repository": "https://github.com/iamcco/markdown-preview.vim.git",
|
||||
"author": "年糕小豆汤 <ooiss@qq.com>",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@chemzqm/neovim": "5.7.9",
|
||||
"log4js": "3.0.6",
|
||||
"neovim": "4.2.1",
|
||||
"socket.io": "2.1.1",
|
||||
"tslib": "1.9.3",
|
||||
"vim-node-rpc": "0.1.24"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Setup hook for checking whether Python imports succeed
|
||||
echo "Sourcing neovim-require-check-hook.sh"
|
||||
|
||||
neovimRequireCheckHook () {
|
||||
echo "Executing neovimRequireCheckHook"
|
||||
|
||||
if [ -n "$nvimRequireCheck" ]; then
|
||||
echo "Check whether the following module can be imported: $nvimRequireCheck"
|
||||
|
||||
# editorconfig-checker-disable
|
||||
export HOME="$TMPDIR"
|
||||
@nvimBinary@ -es --headless -n -u NONE -i NONE --clean -V1 \
|
||||
--cmd "set rtp+=$out" \
|
||||
--cmd "lua require('$nvimRequireCheck')"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Using neovimRequireCheckHook"
|
||||
preDistPhases+=" neovimRequireCheckHook"
|
||||
|
||||
|
||||
1192
pkgs/applications/editors/vim/plugins/overrides.nix
Normal file
1192
pkgs/applications/editors/vim/plugins/overrides.nix
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,25 @@
|
|||
diff --git a/rplugin/python3/fruzzy_mod.nim b/rplugin/python3/fruzzy_mod.nim
|
||||
index dba0689..0109285 100644
|
||||
--- a/rplugin/python3/fruzzy_mod.nim
|
||||
+++ b/rplugin/python3/fruzzy_mod.nim
|
||||
@@ -12,9 +12,7 @@ when defined(profile):
|
||||
import nimprof
|
||||
|
||||
proc getVersion(): string {.compileTime.}=
|
||||
- let ver = staticExec("git describe --tags --always --dirty").strip()
|
||||
- # let cTime = format(times.now(), "yyyy-MM-dd hh:mm:ss")
|
||||
- let branch = staticExec("git rev-parse --abbrev-ref HEAD").strip()
|
||||
+ let ver = "@version@"
|
||||
var options:seq[string] = newSeq[string]()
|
||||
if not defined(removelogger):
|
||||
options.add("info")
|
||||
@@ -26,7 +24,7 @@ proc getVersion(): string {.compileTime.}=
|
||||
options.add("release")
|
||||
let optionsStr = options.join(",")
|
||||
|
||||
- return &"rev: {ver} on branch: {branch} with options: {optionsStr}"
|
||||
+ return &"version: {ver} with options: {optionsStr}"
|
||||
|
||||
let L = newConsoleLogger(levelThreshold = logging.Level.lvlDebug)
|
||||
addHandler(L)
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
diff --git a/doc/lens.txt b/doc/lens.txt
|
||||
index 60943ce..2fe43dc 100644
|
||||
--- a/doc/lens.txt
|
||||
+++ b/doc/lens.txt
|
||||
@@ -76,7 +76,6 @@ g:lens#disabled_filenames
|
||||
|
||||
Default value is [].
|
||||
*g:lens#animate*
|
||||
- *g:lens#animate*
|
||||
g:lens#animate
|
||||
If value is 1 and animate.vim is installed, the window resize
|
||||
will be animated.
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
diff --git a/lua/sniprun.lua b/lua/sniprun.lua
|
||||
index aa39e0b..188d54a 100644
|
||||
--- a/lua/sniprun.lua
|
||||
+++ b/lua/sniprun.lua
|
||||
@@ -4,9 +4,7 @@ M.custom_highlight=false
|
||||
M.info_floatwin = {}
|
||||
|
||||
-- See https://github.com/tjdevries/rofl.nvim/blob/632c10f2ec7c56882a3f7eda8849904bcac6e8af/lua/rofl.lua
|
||||
-local binary_path = vim.fn.fnamemodify(
|
||||
- vim.api.nvim_get_runtime_file("lua/sniprun.lua", false)[1], ":h:h")
|
||||
- .. "/target/release/sniprun"
|
||||
+local binary_path = "@sniprun_bin@/bin/sniprun"
|
||||
|
||||
local sniprun_path = vim.fn.fnamemodify( vim.api.nvim_get_runtime_file("lua/sniprun.lua", false)[1], ":p:h") .. "/.."
|
||||
|
||||
diff --git a/ressources/init_repl.sh b/ressources/init_repl.sh
|
||||
index 2e6264d..0eab1c6 100644
|
||||
--- a/ressources/init_repl.sh
|
||||
+++ b/ressources/init_repl.sh
|
||||
@@ -23,7 +23,7 @@ mkfifo $working_dir/$pipe
|
||||
touch $working_dir/$out
|
||||
sleep 36000 > $working_dir/$pipe &
|
||||
|
||||
-echo "/bin/cat " $working_dir/$pipe " | " $repl > $working_dir/real_launcher.sh
|
||||
+echo "cat " $working_dir/$pipe " | " $repl > $working_dir/real_launcher.sh
|
||||
chmod +x $working_dir/real_launcher.sh
|
||||
|
||||
echo $repl " process started at $(date +"%F %T")." >> $working_dir/log
|
||||
diff --git a/ressources/launcher_repl.sh b/ressources/launcher_repl.sh
|
||||
index feaa91e..749c55e 100755
|
||||
--- a/ressources/launcher_repl.sh
|
||||
+++ b/ressources/launcher_repl.sh
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
-/bin/cat $1 > $2
|
||||
+cat $1 > $2
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- vim-grammarous-51ef519.org/autoload/grammarous.vim 1970-01-01 01:00:01.000000000 +0100
|
||||
+++ vim-grammarous-51ef519/autoload/grammarous.vim 2017-11-21 16:33:27.473403322 +0000
|
||||
@@ -22,7 +22,7 @@
|
||||
let g:grammarous#enable_spell_check = get(g:, 'grammarous#enable_spell_check', 0)
|
||||
let g:grammarous#move_to_first_error = get(g:, 'grammarous#move_to_first_error', 1)
|
||||
let g:grammarous#hooks = get(g:, 'grammarous#hooks', {})
|
||||
-let g:grammarous#languagetool_cmd = get(g:, 'grammarous#languagetool_cmd', '')
|
||||
+let g:grammarous#languagetool_cmd = get(g:, 'grammarous#languagetool_cmd', '@languagetool@/bin/languagetool-commandline')
|
||||
let g:grammarous#show_first_error = get(g:, 'grammarous#show_first_error', 0)
|
||||
|
||||
highlight default link GrammarousError SpellBad
|
||||
1
pkgs/applications/editors/vim/plugins/readme.md
Normal file
1
pkgs/applications/editors/vim/plugins/readme.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Instructions for adding Vim plugins to `nixpkgs` can be found [here](/doc/languages-frameworks/vim.section.md).
|
||||
16
pkgs/applications/editors/vim/plugins/update-shell.nix
Normal file
16
pkgs/applications/editors/vim/plugins/update-shell.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ pkgs ? import ../../../../.. { } }:
|
||||
|
||||
# Ideally, pkgs points to default.nix file of Nixpkgs official tree
|
||||
with pkgs;
|
||||
let
|
||||
pyEnv = python3.withPackages (ps: [ ps.GitPython ]);
|
||||
in
|
||||
|
||||
mkShell {
|
||||
packages = [
|
||||
bash
|
||||
pyEnv
|
||||
nix
|
||||
nix-prefetch-scripts
|
||||
];
|
||||
}
|
||||
134
pkgs/applications/editors/vim/plugins/update.py
Executable file
134
pkgs/applications/editors/vim/plugins/update.py
Executable file
|
|
@ -0,0 +1,134 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell update-shell.nix -i python3
|
||||
|
||||
|
||||
# format:
|
||||
# $ nix run nixpkgs.python3Packages.black -c black update.py
|
||||
# type-check:
|
||||
# $ nix run nixpkgs.python3Packages.mypy -c mypy update.py
|
||||
# linted:
|
||||
# $ nix run nixpkgs.python3Packages.flake8 -c 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 os
|
||||
import sys
|
||||
import logging
|
||||
import textwrap
|
||||
from typing import List, Tuple
|
||||
from pathlib import Path
|
||||
|
||||
log = logging.getLogger()
|
||||
|
||||
sh = logging.StreamHandler()
|
||||
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
|
||||
sh.setFormatter(formatter)
|
||||
log.addHandler(sh)
|
||||
|
||||
# Import plugin update library from maintainers/scripts/pluginupdate.py
|
||||
ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
|
||||
# Ideally, ROOT.(parent^5) points to root of Nixpkgs official tree
|
||||
sys.path.insert(0, os.path.join(ROOT.parent.parent.parent.parent.parent, "maintainers", "scripts"))
|
||||
import pluginupdate
|
||||
from pluginupdate import run_nix_expr, PluginDesc
|
||||
|
||||
GET_PLUGINS = f"""(with import <localpkgs> {{}};
|
||||
let
|
||||
inherit (vimUtils.override {{inherit vim;}}) buildNeovimPluginFrom2Nix buildVimPluginFrom2Nix;
|
||||
generated = callPackage {ROOT}/generated.nix {{
|
||||
inherit buildNeovimPluginFrom2Nix buildVimPluginFrom2Nix;
|
||||
}};
|
||||
hasChecksum = value: lib.isAttrs value && lib.hasAttrByPath ["src" "outputHash"] value;
|
||||
getChecksum = name: value:
|
||||
if hasChecksum value then {{
|
||||
submodules = value.src.fetchSubmodules or false;
|
||||
sha256 = value.src.outputHash;
|
||||
rev = value.src.rev;
|
||||
}} else null;
|
||||
checksums = lib.mapAttrs getChecksum generated;
|
||||
in lib.filterAttrs (n: v: v != null) checksums)"""
|
||||
|
||||
GET_PLUGINS_LUA = """
|
||||
with import <localpkgs> {};
|
||||
lib.attrNames lua51Packages"""
|
||||
|
||||
HEADER = (
|
||||
"# This file has been generated by ./pkgs/applications/editors/vim/plugins/update.py. Do not edit!"
|
||||
)
|
||||
|
||||
def isNeovimPlugin(plug: pluginupdate.Plugin) -> bool:
|
||||
'''
|
||||
Whether it's a neovim-only plugin
|
||||
We can check if it's available in lua packages
|
||||
'''
|
||||
global luaPlugins
|
||||
if plug.normalized_name in luaPlugins:
|
||||
log.debug("%s is a neovim plugin", plug)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class VimEditor(pluginupdate.Editor):
|
||||
def generate_nix(self, plugins: List[Tuple[PluginDesc, pluginupdate.Plugin]], outfile: str):
|
||||
sorted_plugins = sorted(plugins, key=lambda v: v[0].name.lower())
|
||||
|
||||
with open(outfile, "w+") as f:
|
||||
f.write(HEADER)
|
||||
f.write(textwrap.dedent("""
|
||||
{ lib, buildVimPluginFrom2Nix, buildNeovimPluginFrom2Nix, fetchFromGitHub, fetchgit }:
|
||||
|
||||
final: prev:
|
||||
{
|
||||
"""
|
||||
))
|
||||
for pdesc, plugin in sorted_plugins:
|
||||
content = self.plugin2nix(pdesc, plugin)
|
||||
f.write(content)
|
||||
f.write("\n}\n")
|
||||
print(f"updated {outfile}")
|
||||
|
||||
def plugin2nix(self, pdesc: PluginDesc, plugin: pluginupdate.Plugin) -> str:
|
||||
|
||||
repo = pdesc.repo
|
||||
isNeovim = isNeovimPlugin(plugin)
|
||||
|
||||
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}";
|
||||
}};
|
||||
|
||||
""".format(
|
||||
buildFn="buildNeovimPluginFrom2Nix" if isNeovim else "buildVimPluginFrom2Nix", plugin=plugin, src_nix=src_nix, repo=repo)
|
||||
print(content)
|
||||
return content
|
||||
|
||||
def main():
|
||||
|
||||
global luaPlugins
|
||||
|
||||
# whitelist
|
||||
luaPlugins = run_nix_expr(GET_PLUGINS_LUA) + [
|
||||
"diffview-nvim",
|
||||
"marks-nvim",
|
||||
"nvim-biscuits"
|
||||
]
|
||||
|
||||
editor = VimEditor("vim", ROOT, GET_PLUGINS)
|
||||
parser = editor.create_parser()
|
||||
args = parser.parse_args()
|
||||
pluginupdate.update_plugins(editor, args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Setup hook for checking whether a vim command exists
|
||||
echo "Sourcing vim-command-check-hook.sh"
|
||||
|
||||
vimCommandCheckHook () {
|
||||
echo "Executing vimCommandCheckHook"
|
||||
|
||||
if [ -n "$vimCommandCheck" ]; then
|
||||
echo "Check whether the following modules can be imported: $vimCommandCheck"
|
||||
|
||||
# editorconfig-checker-disable
|
||||
export HOME="$TMPDIR"
|
||||
@vimBinary@ -es -n -u NONE -i NONE --clean -V1 --cmd "set rtp+=$out" \
|
||||
--cmd "runtime! plugin/*.vim" <<-EOF
|
||||
if exists(":$vimCommandCheck") == 2
|
||||
cquit 0
|
||||
else
|
||||
cquit 1
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Using vimCommandCheckHook"
|
||||
preDistPhases+=" vimCommandCheckHook"
|
||||
|
||||
30
pkgs/applications/editors/vim/plugins/vim-gen-doc-hook.sh
Normal file
30
pkgs/applications/editors/vim/plugins/vim-gen-doc-hook.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
echo "Sourcing vim-gen-doc-hook"
|
||||
|
||||
# the doc folder is copied via the copy_directories entry of the rockspec
|
||||
# in the folder gitsigns.nvim-scm-1-rocks/gitsigns.nvim/scm-1
|
||||
vimPluginGenTags() {
|
||||
echo "Executing vimPluginGenTags"
|
||||
|
||||
target="$out/@rtpPath@"
|
||||
mkdir -p $out/@rtpPath@
|
||||
|
||||
# build help tags
|
||||
if [ -d "$target/doc" ]; then
|
||||
echo "Building help tags"
|
||||
if ! @vimBinary@ -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then
|
||||
echo "Failed to build help tags!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No docs available for $target"
|
||||
fi
|
||||
|
||||
if [ -n "$addonInfo" ]; then
|
||||
echo "$addonInfo" > $target/addon-info.json
|
||||
fi
|
||||
|
||||
echo "Finished executing vimPluginInstallPhase"
|
||||
}
|
||||
|
||||
preFixupHooks+=(vimPluginGenTags)
|
||||
|
||||
1031
pkgs/applications/editors/vim/plugins/vim-plugin-names
Normal file
1031
pkgs/applications/editors/vim/plugins/vim-plugin-names
Normal file
File diff suppressed because it is too large
Load diff
578
pkgs/applications/editors/vim/plugins/vim-utils.nix
Normal file
578
pkgs/applications/editors/vim/plugins/vim-utils.nix
Normal file
|
|
@ -0,0 +1,578 @@
|
|||
# tests available at pkgs/test/vim
|
||||
{ lib, stdenv, vim, vimPlugins, vim_configurable, buildEnv, writeText
|
||||
, runCommand, makeWrapper
|
||||
, nix-prefetch-hg, nix-prefetch-git
|
||||
, fetchFromGitHub, runtimeShell
|
||||
, hasLuaModule
|
||||
, python3
|
||||
, callPackage, makeSetupHook
|
||||
}:
|
||||
|
||||
/*
|
||||
|
||||
USAGE EXAMPLE
|
||||
=============
|
||||
|
||||
Install Vim like this eg using nixos option environment.systemPackages which will provide
|
||||
vim-with-plugins in PATH:
|
||||
|
||||
vim_configurable.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
|
||||
};
|
||||
|
||||
# plugins can also be managed by VAM
|
||||
vimrcConfig.vam.knownPlugins = pkgs.vimPlugins; # optional
|
||||
vimrcConfig.vam.pluginDictionaries = [
|
||||
# load always
|
||||
{ name = "youcompleteme"; }
|
||||
{ names = ["youcompleteme" "foo"]; }
|
||||
|
||||
# only load when opening a .php file
|
||||
{ name = "phpCompletion"; ft_regex = "^php\$"; }
|
||||
{ name = "phpCompletion"; filename_regex = "^.php\$"; }
|
||||
|
||||
# provide plugin which can be loaded manually:
|
||||
{ name = "phpCompletion"; tag = "lazy"; }
|
||||
|
||||
# full documentation at github.com/MarcWeber/vim-addon-manager
|
||||
];
|
||||
|
||||
# there is a pathogen implementation as well, but its startup is slower and [VAM] has more feature
|
||||
# vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional
|
||||
# vimrcConfig.pathogen.pluginNames = ["vim-addon-nix"];
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
which is what the [VAM]/pathogen solutions above basically do.
|
||||
|
||||
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 mantained 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 DERVITATIONS 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_configurable;
|
||||
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 = ".";
|
||||
|
||||
# Generates a packpath folder as expected by vim
|
||||
packDir = packages:
|
||||
let
|
||||
# dir is "start" or "opt"
|
||||
linkLuaPlugin = plugin: packageName: dir: ''
|
||||
mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua
|
||||
ln -sf ${plugin}/share/lua/5.1/* $out/pack/${packageName}/${dir}/${plugin.pname}/lua
|
||||
ln -sf ${plugin}/${plugin.pname}-${plugin.version}-rocks/${plugin.pname}/${plugin.version}/* $out/pack/${packageName}/${dir}/${plugin.pname}/
|
||||
'';
|
||||
|
||||
linkVimlPlugin = plugin: packageName: dir: ''
|
||||
mkdir -p $out/pack/${packageName}/${dir}
|
||||
if test -e "$out/pack/${packageName}/${dir}/${lib.getName plugin}"; then
|
||||
printf "\nERROR - Duplicated vim plugin: ${lib.getName plugin}\n\n"
|
||||
exit 1
|
||||
fi
|
||||
ln -sf ${plugin}/${rtpPath} $out/pack/${packageName}/${dir}/${lib.getName plugin}
|
||||
'';
|
||||
|
||||
link = pluginPath: if hasLuaModule pluginPath
|
||||
then linkLuaPlugin pluginPath
|
||||
else linkVimlPlugin pluginPath;
|
||||
|
||||
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);
|
||||
python3Env = python3.withPackages (ps:
|
||||
lib.flatten (builtins.map (plugin: (plugin.python3Dependencies or (_: [])) ps) allPlugins)
|
||||
);
|
||||
in
|
||||
[ "mkdir -p $out/pack/${packageName}/start" ]
|
||||
# To avoid confusion, even dependencies of optional plugins are added
|
||||
# to `start` (except if they are explicitly listed as optional plugins).
|
||||
++ (builtins.map (x: link x packageName "start") allPlugins)
|
||||
++ ["mkdir -p $out/pack/${packageName}/opt"]
|
||||
++ (builtins.map (x: link x packageName "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.
|
||||
++ [
|
||||
"mkdir -p $out/pack/${packageName}/start/__python3_dependencies"
|
||||
"ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3"
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "vim-pack-dir";
|
||||
src = ./.;
|
||||
installPhase = lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList packageLinks packages));
|
||||
preferLocalBuild = true;
|
||||
};
|
||||
|
||||
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,
|
||||
pathogen ? null,
|
||||
plug ? null,
|
||||
beforePlugins ? ''
|
||||
" configuration generated by NIX
|
||||
set nocompatible
|
||||
'',
|
||||
customRC ? null
|
||||
}:
|
||||
|
||||
let
|
||||
/* pathogen mostly can set &rtp at startup time. Its used very commonly.
|
||||
*/
|
||||
pathogenImpl = let
|
||||
knownPlugins = pathogen.knownPlugins or vimPlugins;
|
||||
|
||||
plugins = findDependenciesRecursively (map (pluginToDrv knownPlugins) pathogen.pluginNames);
|
||||
|
||||
pluginsEnv = buildEnv {
|
||||
name = "pathogen-plugin-env";
|
||||
paths = map (x: "${x}/${rtpPath}") plugins;
|
||||
};
|
||||
in
|
||||
''
|
||||
let &rtp.=(empty(&rtp)?"":',')."${vimPlugins.vim-pathogen.rtp}"
|
||||
execute pathogen#infect('${pluginsEnv}/{}')
|
||||
|
||||
filetype indent plugin on | syn on
|
||||
'';
|
||||
|
||||
/* vim-plug is an extremely popular vim plugin manager.
|
||||
*/
|
||||
plugImpl =
|
||||
(''
|
||||
source ${vimPlugins.vim-plug.rtp}/plug.vim
|
||||
silent! call plug#begin('/dev/null')
|
||||
|
||||
'' + (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg.rtp}'") plug.plugins) + ''
|
||||
|
||||
call plug#end()
|
||||
'');
|
||||
|
||||
/*
|
||||
vim-addon-manager = VAM
|
||||
|
||||
* maps names to plugin location
|
||||
|
||||
* manipulates &rtp at startup time
|
||||
or when Vim has been running for a while
|
||||
|
||||
* can activate plugins laziy (eg when loading a specific filetype)
|
||||
|
||||
* knows about vim plugin dependencies (addon-info.json files)
|
||||
|
||||
* still is minimalistic (only loads one file), the "check out" code it also
|
||||
has only gets loaded when a plugin is requested which is not found on disk
|
||||
yet
|
||||
|
||||
*/
|
||||
vamImpl = lib.optionalString (vam != null)
|
||||
(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;
|
||||
|
||||
# Convert scalars, lists, and attrs, to VimL equivalents
|
||||
toVimL = x:
|
||||
if builtins.isString x then "'${lib.replaceStrings [ "\n" "'" ] [ "\n\\ " "''" ] x}'"
|
||||
else if builtins.isAttrs x && builtins ? out then toVimL x # a derivation
|
||||
else if builtins.isAttrs x then "{${lib.concatStringsSep ", " (lib.mapAttrsToList (n: v: "${toVimL n}: ${toVimL v}") x)}}"
|
||||
else if builtins.isList x then "[${lib.concatMapStringsSep ", " toVimL x}]"
|
||||
else if builtins.isInt x || builtins.isFloat x then builtins.toString x
|
||||
else if builtins.isBool x then (if x then "1" else "0")
|
||||
else throw "turning ${lib.generators.toPretty {} x} into a VimL thing not implemented yet";
|
||||
|
||||
in assert builtins.hasAttr "vim-addon-manager" knownPlugins;
|
||||
''
|
||||
filetype indent plugin on | syn on
|
||||
|
||||
let g:nix_plugin_locations = {}
|
||||
${lib.concatMapStrings (plugin: ''
|
||||
let g:nix_plugin_locations['${plugin.pname}'] = "${plugin.rtp}"
|
||||
'') plugins}
|
||||
let g:nix_plugin_locations['vim-addon-manager'] = "${knownPlugins.vim-addon-manager.rtp}"
|
||||
|
||||
let g:vim_addon_manager = {}
|
||||
|
||||
if exists('g:nix_plugin_locations')
|
||||
" nix managed config
|
||||
|
||||
" override default function making VAM aware of plugin locations:
|
||||
fun! NixPluginLocation(name)
|
||||
let path = get(g:nix_plugin_locations, a:name, "")
|
||||
return path == "" ? vam#DefaultPluginDirFromName(a:name) : path
|
||||
endfun
|
||||
let g:vim_addon_manager.plugin_dir_by_name = 'NixPluginLocation'
|
||||
" tell Vim about VAM:
|
||||
let &rtp.=(empty(&rtp)?"":','). g:nix_plugin_locations['vim-addon-manager']
|
||||
else
|
||||
" standalone config
|
||||
|
||||
let &rtp.=(empty(&rtp)?"":',').c.plugin_root_dir.'/vim-addon-manager'
|
||||
if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
|
||||
" checkout VAM
|
||||
execute '!git clone --depth=1 https://github.com/MarcWeber/vim-addon-manager '
|
||||
\ shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
" tell vam which plugins to load, and when:
|
||||
let l = []
|
||||
${lib.concatMapStrings (p: "call add(l, ${toVimL p})\n") vam.pluginDictionaries}
|
||||
call vam#Scripts(l, {})
|
||||
'');
|
||||
|
||||
entries = [
|
||||
beforePlugins
|
||||
vamImpl
|
||||
]
|
||||
++ lib.optional (packages != null && packages != []) (nativeImpl packages)
|
||||
++ lib.optional (pathogen != null) pathogenImpl
|
||||
++ 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 if wrapManual == false && name == "vim" then "Set `standalone = true` to get the *vim wrappers only."
|
||||
else ""}''
|
||||
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" { buildInputs = [ makeWrapper ]; } ''
|
||||
vimrc=${lib.escapeShellArg vimrc}
|
||||
gvimrc=${if gvimrcFile != null then lib.escapeShellArg gvimrcFile else ""}
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
vimWithRC = throw "vimWithRC was removed, please use vim.customize instead";
|
||||
|
||||
pluginnames2Nix = {name, namefiles} : vim_configurable.customize {
|
||||
inherit name;
|
||||
vimrcConfig.vam.knownPlugins = vimPlugins;
|
||||
vimrcConfig.vam.pluginDictionaries = ["vim2nix"];
|
||||
vimrcConfig.customRC = ''
|
||||
" Yes - this is impure and will create the cache file and checkout vim-pi
|
||||
" into ~/.vim/vim-addons
|
||||
let g:vim_addon_manager.plugin_root_dir = "/tmp/vim2nix-".$USER
|
||||
if !isdirectory(g:vim_addon_manager.plugin_root_dir)
|
||||
call mkdir(g:vim_addon_manager.plugin_root_dir)
|
||||
else
|
||||
echom repeat("=", 80)
|
||||
echom "WARNING: reusing cache directory :".g:vim_addon_manager.plugin_root_dir
|
||||
echom repeat("=", 80)
|
||||
endif
|
||||
let opts = {}
|
||||
let opts.nix_prefetch_git = "${nix-prefetch-git}/bin/nix-prefetch-git"
|
||||
let opts.nix_prefetch_hg = "${nix-prefetch-hg}/bin/nix-prefetch-hg"
|
||||
let opts.cache_file = g:vim_addon_manager.plugin_root_dir.'/cache'
|
||||
let opts.plugin_dictionaries = []
|
||||
${lib.concatMapStrings (file: "let opts.plugin_dictionaries += map(readfile(\"${file}\"), 'eval(v:val)')\n") namefiles }
|
||||
|
||||
" uncomment for debugging failures
|
||||
" let opts.try_catch = 0
|
||||
|
||||
" add more files
|
||||
" let opts.plugin_dictionaries += map(.. other file )
|
||||
call nix#ExportPluginsForNix(opts)
|
||||
'';
|
||||
};
|
||||
|
||||
vimGenDocHook = callPackage ({ vim }:
|
||||
makeSetupHook {
|
||||
name = "vim-gen-doc-hook";
|
||||
deps = [ vim ];
|
||||
substitutions = {
|
||||
vimBinary = "${vim}/bin/vim";
|
||||
inherit rtpPath;
|
||||
};
|
||||
} ./vim-gen-doc-hook.sh) {};
|
||||
|
||||
vimCommandCheckHook = callPackage ({ neovim-unwrapped }:
|
||||
makeSetupHook {
|
||||
name = "vim-command-check-hook";
|
||||
deps = [ neovim-unwrapped ];
|
||||
substitutions = {
|
||||
vimBinary = "${neovim-unwrapped}/bin/nvim";
|
||||
inherit rtpPath;
|
||||
};
|
||||
} ./vim-command-check-hook.sh) {};
|
||||
|
||||
neovimRequireCheckHook = callPackage ({ neovim-unwrapped }:
|
||||
makeSetupHook {
|
||||
name = "neovim-require-check-hook";
|
||||
deps = [ neovim-unwrapped ];
|
||||
substitutions = {
|
||||
nvimBinary = "${neovim-unwrapped}/bin/nvim";
|
||||
inherit rtpPath;
|
||||
};
|
||||
} ./neovim-require-check-hook.sh) {};
|
||||
|
||||
inherit (import ./build-vim-plugin.nix {
|
||||
inherit lib stdenv rtpPath vim vimGenDocHook vimCommandCheckHook neovimRequireCheckHook;
|
||||
}) buildVimPlugin buildVimPluginFrom2Nix;
|
||||
|
||||
|
||||
# TODO placeholder to ease working on automatic plugin detection
|
||||
# this should be a luarocks "flat" install with appropriate vim hooks
|
||||
buildNeovimPluginFrom2Nix = attrs: let drv = (buildVimPluginFrom2Nix attrs); in drv.overrideAttrs(oa: {
|
||||
nativeBuildInputs = oa.nativeBuildInputs ++ [ neovimRequireCheckHook ];
|
||||
});
|
||||
|
||||
# used to figure out which python dependencies etc. neovim needs
|
||||
requiredPlugins = {
|
||||
packages ? {},
|
||||
givenKnownPlugins ? null,
|
||||
vam ? null,
|
||||
pathogen ? null,
|
||||
plug ? null, ...
|
||||
}:
|
||||
let
|
||||
# This is probably overcomplicated, but I don't understand this well enough to know what's necessary.
|
||||
knownPlugins = if givenKnownPlugins != null then givenKnownPlugins else
|
||||
if vam != null && vam ? knownPlugins then vam.knownPlugins else
|
||||
if pathogen != null && pathogen ? knownPlugins then pathogen.knownPlugins else
|
||||
vimPlugins;
|
||||
pathogenPlugins = findDependenciesRecursively (map (pluginToDrv knownPlugins) pathogen.pluginNames);
|
||||
vamPlugins = findDependenciesRecursively (map (pluginToDrv knownPlugins) (lib.concatMap vamDictToNames vam.pluginDictionaries));
|
||||
nonNativePlugins = (lib.optionals (pathogen != null) pathogenPlugins)
|
||||
++ (lib.optionals (vam != null) vamPlugins)
|
||||
++ (lib.optionals (plug != null) plug.plugins);
|
||||
nativePluginsConfigs = lib.attrsets.attrValues packages;
|
||||
nativePlugins = lib.concatMap ({start?[], opt?[], knownPlugins?vimPlugins}: start++opt) nativePluginsConfigs;
|
||||
in
|
||||
nativePlugins ++ nonNativePlugins;
|
||||
}
|
||||
3
pkgs/applications/editors/vim/plugins/vim2nix/README.txt
Normal file
3
pkgs/applications/editors/vim/plugins/vim2nix/README.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Usage see vim-utils.nix in nixpkgs
|
||||
|
||||
This code depends on vim-addon-manager
|
||||
|
|
@ -0,0 +1 @@
|
|||
{'dependencies': {'vim-addon-manager': {}}}
|
||||
307
pkgs/applications/editors/vim/plugins/vim2nix/autoload/nix.vim
Normal file
307
pkgs/applications/editors/vim/plugins/vim2nix/autoload/nix.vim
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
" usage example:
|
||||
"
|
||||
" call nix#ExportPluginsForNix({'path_to_nixpkgs': '/etc/nixos/nixpkgs', 'names': ["vim-addon-manager", "vim-addon-nix"], 'cache_file': 'cache'})
|
||||
let s:plugin_root = expand('<sfile>:h:h')
|
||||
|
||||
fun! nix#ToNixAttrName(s) abort
|
||||
return nix#ToNixName(a:s)
|
||||
endf
|
||||
|
||||
fun! nix#ToNixName(s) abort
|
||||
return substitute(substitute(a:s, '[:/.]', '-', 'g'), 'github-', '', 'g')
|
||||
endf
|
||||
|
||||
fun! s:System(...)
|
||||
let args = a:000
|
||||
let r = call('vam#utils#System', args)
|
||||
if r is 0
|
||||
throw "command ".join(args, '').' failed'
|
||||
else
|
||||
return r
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! nix#DependenciesFromCheckout(opts, name, repository, dir)
|
||||
" check for dependencies
|
||||
" vam#PluginDirFromName(a:name)
|
||||
let info = vam#ReadAddonInfo(vam#AddonInfoFile(a:dir, a:name))
|
||||
return keys(get(info, 'dependencies', {}))
|
||||
endf
|
||||
|
||||
|
||||
" without deps
|
||||
fun! nix#NixDerivation(opts, name, repository) abort
|
||||
let n_a_name = nix#ToNixAttrName(a:name)
|
||||
let n_n_name = nix#ToNixName(a:name)
|
||||
let type = get(a:repository, 'type', '')
|
||||
let created_notice = " # created by nix#NixDerivation"
|
||||
|
||||
let ancf = s:plugin_root.'/additional-nix-code/'.a:name
|
||||
let additional_nix_code = file_readable(ancf) ? join(readfile(ancf), "\n") : ""
|
||||
|
||||
if type == 'git'
|
||||
" should be using shell abstraction ..
|
||||
echo 'fetching '. a:repository.url
|
||||
let s = s:System('$ --fetch-submodules $ 2>&1',a:opts.nix_prefetch_git, a:repository.url)
|
||||
let rev = matchstr(s, 'git revision is \zs[^\n\r]\+\ze')
|
||||
let sha256 = matchstr(s, 'hash is \zs[^\n\r]\+\ze')
|
||||
let dir = matchstr(s, 'path is \zs[^\n\r]\+\ze')
|
||||
let date = matchstr(s, 'Commit date is \zs[0-9-]\+\ze')
|
||||
|
||||
let dependencies = nix#DependenciesFromCheckout(a:opts, a:name, a:repository, dir)
|
||||
return {'n_a_name': n_a_name, 'n_n_name': n_n_name, 'dependencies': dependencies, 'derivation': join([
|
||||
\ ' '.n_a_name.' = buildVimPluginFrom2Nix {'.created_notice,
|
||||
\ ' name = "'.n_n_name.'-'.date.'";',
|
||||
\ ' src = fetchgit {',
|
||||
\ ' url = "'. a:repository.url .'";',
|
||||
\ ' rev = "'.rev.'";',
|
||||
\ ' sha256 = "'.sha256.'";',
|
||||
\ ' };',
|
||||
\ ' dependencies = ['.join(map(copy(dependencies), "'\"'.nix#ToNixAttrName(v:val).'\"'")).'];',
|
||||
\ additional_nix_code,
|
||||
\ ' };',
|
||||
\ '',
|
||||
\ '',
|
||||
\ ], "\n")}
|
||||
|
||||
elseif type == 'hg'
|
||||
" should be using shell abstraction ..
|
||||
echo 'fetching '. a:repository.url
|
||||
let s = s:System('$ $ 2>&1',a:opts.nix_prefetch_hg, a:repository.url)
|
||||
let rev = matchstr(s, 'hg revision is \zs[^\n\r]\+\ze')
|
||||
let sha256 = matchstr(s, 'hash is \zs[^\n\r]\+\ze')
|
||||
let dir = matchstr(s, 'path is \zs[^\n\r]\+\ze')
|
||||
|
||||
let dependencies = nix#DependenciesFromCheckout(a:opts, a:name, a:repository, dir)
|
||||
return {'n_a_name': n_a_name, 'n_n_name': n_n_name, 'dependencies': dependencies, 'derivation': join([
|
||||
\ ' '.n_a_name.' = buildVimPluginFrom2Nix {'.created_notice,
|
||||
\ ' name = "'.n_n_name.'";',
|
||||
\ ' src = fetchhg {',
|
||||
\ ' url = "'. a:repository.url .'";',
|
||||
\ ' rev = "'.rev.'";',
|
||||
\ ' sha256 = "'.sha256.'";',
|
||||
\ ' };',
|
||||
\ ' dependencies = ['.join(map(copy(dependencies), "'\"'.nix#ToNixAttrName(v:val).'\"'")).'];',
|
||||
\ additional_nix_code,
|
||||
\ ' };',
|
||||
\ '',
|
||||
\ '',
|
||||
\ ], "\n")}
|
||||
|
||||
elseif type == 'archive'
|
||||
let sha256 = split(s:System('nix-prefetch-url $ 2>/dev/null', a:repository.url), "\n")[0]
|
||||
" we should unpack the sources, look for the addon-info.json file ..
|
||||
" however most packages who have the addon-info.json file also are on
|
||||
" github thus will be of type "git" instead. The dependency information
|
||||
" from vim-pi is encoded in the reposiotry. Thus this is likely to do the
|
||||
" right thing most of the time.
|
||||
let addon_info = get(a:repository, 'addon-info', {})
|
||||
let dependencies = keys(get(addon_info, 'dependencies', {}))
|
||||
|
||||
return {'n_a_name': n_a_name, 'n_n_name': n_n_name, 'dependencies': dependencies, 'derivation': join([
|
||||
\ ' '.n_a_name.' = buildVimPluginFrom2Nix {'.created_notice,
|
||||
\ ' name = "'.n_n_name.'";',
|
||||
\ ' src = fetchurl {',
|
||||
\ ' url = "'. a:repository.url .'";',
|
||||
\ ' name = "'. a:repository.archive_name .'";',
|
||||
\ ' sha256 = "'.sha256.'";',
|
||||
\ ' };',
|
||||
\ ' buildInputs = [ unzip ];',
|
||||
\ ' dependencies = ['.join(map(copy(dependencies), "'\"'.nix#ToNixAttrName(v:val).'\"'")).'];',
|
||||
\ ' meta = {',
|
||||
\ ' homepage = "http://www.vim.org/scripts/script.php?script_id='.a:repository.vim_script_nr.'";',
|
||||
\ ' };',
|
||||
\ addon_info == {} ? '' : (' addon_info = '.nix#ToNix(string(addon_info), [], "").';'),
|
||||
\ additional_nix_code,
|
||||
\ ' };',
|
||||
\ '',
|
||||
\ '',
|
||||
\ ], "\n")}
|
||||
else
|
||||
throw a:name.' TODO: implement source '.string(a:repository)
|
||||
endif
|
||||
endf
|
||||
|
||||
" also tries to handle dependencies
|
||||
fun! nix#AddNixDerivation(opts, cache, name, ...) abort
|
||||
if has_key(a:cache, a:name) | return | endif
|
||||
let repository = a:0 > 0 ? a:1 : {}
|
||||
let name = a:name
|
||||
|
||||
if repository == {}
|
||||
call vam#install#LoadPool()
|
||||
let list = matchlist(a:name, 'github:\([^/]*\)\%(\/\(.*\)\)\?$')
|
||||
if len(list) > 0
|
||||
if '' != list[2]
|
||||
let name = list[2]
|
||||
let repository = { 'type': 'git', 'owner': list[1], 'repo': list[2], 'url': 'https://github.com/'.list[1].'/'.list[2] }
|
||||
else
|
||||
let name = list[1]
|
||||
let repository = { 'type': 'git', 'owner': list[1], 'repo': 'vim-addon-'.list[1], 'url': 'https://github.com/'.list[1].'/vim-addon-'.list[1] }
|
||||
endif
|
||||
else
|
||||
let repository = get(g:vim_addon_manager.plugin_sources, a:name, {})
|
||||
if repository == {}
|
||||
throw "repository ".a:name." unkown!"
|
||||
else
|
||||
if repository.url =~ 'github'
|
||||
let owner = matchstr(repository.url, 'github.com/\zs.\+\ze/')
|
||||
let repo = matchstr(repository.url, '\/\zs[^\/]\+\ze$')
|
||||
let url = repository.url
|
||||
let repository = { 'type': 'git', 'owner': owner, 'repo': repo, 'url': url }
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let a:cache[a:name] = nix#NixDerivation(a:opts, name, repository)
|
||||
|
||||
" take known dependencies into account:
|
||||
let deps = get(a:cache[a:name], 'dependencies', [])
|
||||
call extend(a:opts.names_to_process, deps)
|
||||
call extend(a:opts.names_to_export, deps)
|
||||
endfun
|
||||
|
||||
fun! nix#TopNixOptsByParent(parents)
|
||||
if (a:parents == [])
|
||||
return {'ind': ' ', 'next_ind': ' ', 'sep': "\n"}
|
||||
else
|
||||
return {'ind': '', 'next_ind': '', 'sep': ' '}
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! nix#ToNix(x, parents, opts_fun) abort
|
||||
let opts = a:opts_fun == "" ? "" : call(a:opts_fun, [a:parents])
|
||||
let next_parents = [a:x] + a:parents
|
||||
let seps = a:0 > 1 ? a:2 : []
|
||||
|
||||
let ind = get(opts, 'ind', '')
|
||||
let next_ind = get(opts, 'next_ind', ind.' ')
|
||||
let sep = get(opts, 'sep', ind.' ')
|
||||
|
||||
if type(a:x) == type("")
|
||||
return "''". substitute(a:x, '[$]', '$$', 'g')."''"
|
||||
elseif type(a:x) == type({})
|
||||
let s = ind."{".sep
|
||||
for [k,v] in items(a:x)
|
||||
let s .= '"'.k.'" = '.nix#ToNix(v, next_parents, a:opts_fun).";".sep
|
||||
unlet k v
|
||||
endfor
|
||||
return s.ind."}"
|
||||
|
||||
" let s = ind."{\n"
|
||||
" for [k,v] in items(a:x)
|
||||
" let s .= next_ind . nix#ToNix(k).' = '.nix#ToNix(v, next_ind)."\n"
|
||||
" unlet k v
|
||||
" endfor
|
||||
" return s.ind."}\n"
|
||||
elseif type(a:x) == type([])
|
||||
let s = ind."[".sep
|
||||
for v in a:x
|
||||
let s .= next_ind . nix#ToNix(v, next_parents, a:opts_fun)."".sep
|
||||
unlet v
|
||||
endfor
|
||||
return s.ind."]"
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" with dependencies
|
||||
" opts.cache_file (caches the checkout and dependency information
|
||||
" opts.path_to_nixpkgs or opts.nix_prefetch_{git,hg}
|
||||
" opts.plugin_dictionaries: list of any
|
||||
" - string
|
||||
" - dictionary having key name or names
|
||||
" This is so that plugin script files can be loaded/ merged
|
||||
fun! nix#ExportPluginsForNix(opts) abort
|
||||
let cache_file = get(a:opts, 'cache_file', '')
|
||||
|
||||
let opts = a:opts
|
||||
|
||||
" set nix_prefetch_* scripts
|
||||
for scm in ['git', 'hg']
|
||||
if !has_key(opts, 'nix_prefetch_'.scm)
|
||||
let opts['nix_prefetch_'.scm] = a:opts.path_to_nixpkgs.'/pkgs/build-support/fetch'.scm.'/nix-prefetch-'.scm
|
||||
endif
|
||||
endfor
|
||||
|
||||
" create list of names from dictionaries
|
||||
let a:opts.names_to_process = []
|
||||
for x in a:opts.plugin_dictionaries
|
||||
if type(x) == type('')
|
||||
call add(opts.names_to_process, x)
|
||||
elseif type(x) == type({}) && has_key(x, 'name')
|
||||
call add(opts.names_to_process, x.name)
|
||||
elseif type(x) == type({}) && has_key(x, 'names')
|
||||
call extend(opts.names_to_process, x.names)
|
||||
else
|
||||
throw "unexpected"
|
||||
endif
|
||||
unlet x
|
||||
endfor
|
||||
let a:opts.names_to_export = a:opts.names_to_process
|
||||
|
||||
let cache = (cache_file == '' || !filereadable(cache_file)) ? {} : eval(readfile(cache_file)[0])
|
||||
let failed = {}
|
||||
while len(opts.names_to_process) > 0
|
||||
let name = opts.names_to_process[0]
|
||||
if get(opts, 'try_catch', 1)
|
||||
try
|
||||
call nix#AddNixDerivation(opts, cache, name)
|
||||
catch /.*/
|
||||
echom 'failed : '.name.' '.v:exception
|
||||
let failed[name] = v:exception
|
||||
endtry
|
||||
else
|
||||
call nix#AddNixDerivation(opts, cache, name)
|
||||
endif
|
||||
let opts.names_to_process = opts.names_to_process[1:]
|
||||
endwhile
|
||||
echom join(keys(failed), ", ")
|
||||
echom string(failed)
|
||||
|
||||
if cache_file != ''
|
||||
call writefile([string(cache)], cache_file)
|
||||
endif
|
||||
|
||||
enew
|
||||
|
||||
let uniq = {}
|
||||
for x in a:opts.names_to_export
|
||||
let uniq[x] = 1
|
||||
endfor
|
||||
|
||||
for k in sort(keys(uniq))
|
||||
call append('$', split(cache[k].derivation,"\n"))
|
||||
endfor
|
||||
|
||||
" for VAM users output vam.pluginDictionaries which can be fed to
|
||||
" vim_customizable.customize.vimrc.vam.pluginDictionaries
|
||||
call append('$', ["", "", "", '# vam.pluginDictionaries'])
|
||||
|
||||
let ns = []
|
||||
for x in a:opts.plugin_dictionaries
|
||||
if type(x) == type("")
|
||||
call add(ns, nix#ToNixAttrName(x))
|
||||
elseif type(x) == type({})
|
||||
if has_key(x, 'name')
|
||||
call add(ns, extend({'name': nix#ToNixAttrName(x.name)}, x, "keep"))
|
||||
elseif has_key(x, 'names')
|
||||
call add(ns, extend({'names': map(copy(x.names), 'nix#ToNixAttrName(v:val)')}, x, "keep"))
|
||||
else
|
||||
throw "unexpected"
|
||||
endif
|
||||
else
|
||||
throw "unexpected"
|
||||
endif
|
||||
unlet x
|
||||
endfor
|
||||
|
||||
call append('$', split(nix#ToNix(ns, [], 'nix#TopNixOptsByParent'), "\n"))
|
||||
|
||||
" failures:
|
||||
for [k,v] in items(failed)
|
||||
call append('$', ['# '.k.', failure: '.v])
|
||||
unlet k v
|
||||
endfor
|
||||
endf
|
||||
Loading…
Add table
Add a link
Reference in a new issue