From 4a0a0592db45584b61a10ee2a801969f9a6f35ed Mon Sep 17 00:00:00 2001 From: Arseniy Seroka Date: Sun, 10 Jan 2016 13:19:06 +0300 Subject: [PATCH] vimPlugins: move vim2nix into nixpkgs repo --- pkgs/misc/vim-plugins/default.nix | 25 +- pkgs/misc/vim-plugins/vim-plugin-names | 1 - pkgs/misc/vim-plugins/vim-utils.nix | 4 +- pkgs/misc/vim-plugins/vim2nix/README.txt | 3 + .../vim2nix/additional-nix-code/command-t | 7 + .../vim2nix/additional-nix-code/matchit.zip | 7 + .../vim2nix/additional-nix-code/racer | 4 + .../vim2nix/additional-nix-code/taglist | 6 + .../additional-nix-code/vim-addon-manager | 1 + .../vim2nix/additional-nix-code/vim-hier | 1 + .../vim2nix/additional-nix-code/vim-wakatime | 1 + .../vim2nix/additional-nix-code/vim-xdebug | 1 + .../vim2nix/additional-nix-code/vim-xkbswitch | 5 + .../vim2nix/additional-nix-code/vimproc.vim | 9 + .../vim2nix/additional-nix-code/vimshell.vim | 1 + .../vim2nix/additional-nix-code/youcompleteme | 24 ++ pkgs/misc/vim-plugins/vim2nix/addon-info.json | 1 + .../misc/vim-plugins/vim2nix/autoload/nix.vim | 307 ++++++++++++++++++ 18 files changed, 391 insertions(+), 17 deletions(-) create mode 100644 pkgs/misc/vim-plugins/vim2nix/README.txt create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/command-t create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/matchit.zip create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/racer create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/taglist create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-addon-manager create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-hier create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-wakatime create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xdebug create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xkbswitch create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimproc.vim create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimshell.vim create mode 100644 pkgs/misc/vim-plugins/vim2nix/additional-nix-code/youcompleteme create mode 100644 pkgs/misc/vim-plugins/vim2nix/addon-info.json create mode 100644 pkgs/misc/vim-plugins/vim2nix/autoload/nix.vim diff --git a/pkgs/misc/vim-plugins/default.nix b/pkgs/misc/vim-plugins/default.nix index a2ceb9d1df89..14be330b79bc 100644 --- a/pkgs/misc/vim-plugins/default.nix +++ b/pkgs/misc/vim-plugins/default.nix @@ -14,8 +14,7 @@ in # TL;DR # Add your plugin to ./vim-plugin-names # Generate via `vim-plugin-names-to-nix` -# If plugin is complicated then create a PR to -# https://github.com/jagajaga/vim-addon-vim2nix/tree/master/additional-nix-code +# If plugin is complicated then make changes to ./vim2nix/additional-nix-code # This attrs contains two sections: # The first contains plugins added manually, the second contains plugins @@ -28,9 +27,18 @@ rec { # which recreates this the following derivations based on ./vim-plugin-names pluginnames2nix = vimUtils.pluginnames2Nix { name = "vim-plugin-names-to-nix"; - namefiles = [./vim-plugin-names]; }; + namefiles = [./vim-plugin-names]; + }; # Section I + vim-addon-vim2nix = vim2nix; + + vim2nix = buildVimPluginFrom2Nix { # use it to update plugins + name = "vim2nix"; + src = ./vim2nix; + dependencies = ["vim-addon-manager"]; + }; + # Section II # Update with vimUtils.vimPlugins.pluginnames2Nix command @@ -324,17 +332,6 @@ rec { }; - vim-addon-vim2nix = buildVimPluginFrom2Nix { # created by nix#NixDerivation - name = "vim-addon-vim2nix-2016-01-09"; - src = fetchgit { - url = "git://github.com/JagaJaga/vim-addon-vim2nix"; - rev = "9146b942f51d2682bf0ca00ad74c324340a61b60"; - sha256 = "2e35baf96ae172d2dac8b86b299ff2c87c14a5b4a4a6864dcce17e7e9ed04861"; - }; - dependencies = ["vim-addon-manager"]; - - }; - vim-nix = buildVimPluginFrom2Nix { # created by nix#NixDerivation name = "vim-nix-2015-12-10"; src = fetchgit { diff --git a/pkgs/misc/vim-plugins/vim-plugin-names b/pkgs/misc/vim-plugins/vim-plugin-names index 7195064a20d3..207eed69160c 100644 --- a/pkgs/misc/vim-plugins/vim-plugin-names +++ b/pkgs/misc/vim-plugins/vim-plugin-names @@ -20,7 +20,6 @@ "extradite" "fugitive" "ghcmod" -"github:JagaJaga/vim-addon-vim2nix" "github:ap/vim-css-color" "github:benekastah/neomake" "github:bitc/vim-hdevtools" diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index adb938900663..f39d7093c73b 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -103,7 +103,7 @@ Then create a temp vim file and insert: Then ":source %" it. -nix#ExportPluginsForNix is provided by github.com/JagaJaga/vim-addon-vim2nix +nix#ExportPluginsForNix is provided by ./vim2nix A buffer will open containing the plugin derivation lines as well list fitting the vimrcConfig.vam.pluginDictionaries option. @@ -297,7 +297,7 @@ rec { pluginnames2Nix = {name, namefiles} : vim_configurable.customize { inherit name; vimrcConfig.vam.knownPlugins = vimPlugins; - vimrcConfig.vam.pluginDictionaries = ["vim-addon-vim2nix"]; # Using fork until patch is accepted by upstream + vimrcConfig.vam.pluginDictionaries = ["vim2nix"]; vimrcConfig.customRC = '' " Yes - this is impure and will create the cache file and checkout vim-pi " into ~/.vim/vim-addons diff --git a/pkgs/misc/vim-plugins/vim2nix/README.txt b/pkgs/misc/vim-plugins/vim2nix/README.txt new file mode 100644 index 000000000000..4263481461f1 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/README.txt @@ -0,0 +1,3 @@ +Usage see vim-utils.nix in nixpkgs + +This code depends on vim-addon-manager diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/command-t b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/command-t new file mode 100644 index 000000000000..a29c602b5d7e --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/command-t @@ -0,0 +1,7 @@ + buildInputs = [ perl ruby ]; + buildPhase = '' + pushd ruby/command-t + ruby extconf.rb + make + popd + ''; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/matchit.zip b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/matchit.zip new file mode 100644 index 000000000000..cc9d3fb72640 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/matchit.zip @@ -0,0 +1,7 @@ + unpackPhase = '' + ( + sourceRoot=d + mkdir $sourceRoot; cd $sourceRoot; + unzip $src + ) + ''; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/racer b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/racer new file mode 100644 index 000000000000..57000b870645 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/racer @@ -0,0 +1,4 @@ + buildPhase = '' + find . -type f -not -name 'racer.vim' -exec rm -rf {} \; + rm -rf editors images src + ''; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/taglist b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/taglist new file mode 100644 index 000000000000..90f6e3367a3b --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/taglist @@ -0,0 +1,6 @@ + setSourceRoot = '' + export sourceRoot=taglist + mkdir taglist + mv doc taglist + mv plugin taglist + ''; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-addon-manager b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-addon-manager new file mode 100644 index 000000000000..e3d8dfb69210 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-addon-manager @@ -0,0 +1 @@ + buildInputs = stdenv.lib.optional stdenv.isDarwin Cocoa; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-hier b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-hier new file mode 100644 index 000000000000..d1f756a99d3b --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-hier @@ -0,0 +1 @@ + buildInputs = [ vim ]; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-wakatime b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-wakatime new file mode 100644 index 000000000000..31ffa7f8ff97 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-wakatime @@ -0,0 +1 @@ + buildInputs = [ python ]; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xdebug b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xdebug new file mode 100644 index 000000000000..62a3c22c0369 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xdebug @@ -0,0 +1 @@ + postInstall = false; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xkbswitch b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xkbswitch new file mode 100644 index 000000000000..4e73ac9a73b3 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vim-xkbswitch @@ -0,0 +1,5 @@ + patchPhase = '' + substituteInPlace plugin/xkbswitch.vim \ + --replace /usr/local/lib/libxkbswitch.so ${xkb_switch}/lib/libxkbswitch.so + ''; + buildInputs = [ xkb_switch ]; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimproc.vim b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimproc.vim new file mode 100644 index 000000000000..e720559fa3d6 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimproc.vim @@ -0,0 +1,9 @@ + buildInputs = [ which ]; + + buildPhase = '' + substituteInPlace autoload/vimproc.vim \ + --replace vimproc_mac.so vimproc_unix.so \ + --replace vimproc_linux64.so vimproc_unix.so \ + --replace vimproc_linux32.so vimproc_unix.so + make -f make_unix.mak + ''; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimshell.vim b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimshell.vim new file mode 100644 index 000000000000..5be233050793 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/vimshell.vim @@ -0,0 +1 @@ + dependencies = [ "vimproc-vim" ]; diff --git a/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/youcompleteme b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/youcompleteme new file mode 100644 index 000000000000..625dfcb4f3ee --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/additional-nix-code/youcompleteme @@ -0,0 +1,24 @@ + buildInputs = [ + python go cmake + (if stdenv.isDarwin then llvmPackages.clang else llvmPackages.clang-unwrapped) + llvmPackages.llvm + ] ++ stdenv.lib.optional stdenv.isDarwin Cocoa; + + buildPhase = '' + patchShebangs . + + mkdir build + pushd build + cmake -G "Unix Makefiles" . ../third_party/ycmd/cpp -DPYTHON_LIBRARIES:PATH=${python}/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR:PATH=${python}/include/python2.7 -DUSE_CLANG_COMPLETER=ON -DUSE_SYSTEM_LIBCLANG=ON + make ycm_support_libs -j''${NIX_BUILD_CORES} -l''${NIX_BUILD_CORES}} + ${python}/bin/python ../third_party/ycmd/build.py --gocode-completer --clang-completer --system-libclang + popd + ''; + + meta = { + description = "Fastest non utf-8 aware word and C completion engine for Vim"; + homepage = http://github.com/Valloric/YouCompleteMe; + license = stdenv.lib.licenses.gpl3; + maintainers = with stdenv.lib.maintainers; [marcweber jagajaga]; + platforms = stdenv.lib.platforms.linux; + }; diff --git a/pkgs/misc/vim-plugins/vim2nix/addon-info.json b/pkgs/misc/vim-plugins/vim2nix/addon-info.json new file mode 100644 index 000000000000..93ca9bc129b5 --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/addon-info.json @@ -0,0 +1 @@ +{'dependencies': {'vim-addon-manager': {}}} diff --git a/pkgs/misc/vim-plugins/vim2nix/autoload/nix.vim b/pkgs/misc/vim-plugins/vim2nix/autoload/nix.vim new file mode 100644 index 000000000000..376b7c674d6c --- /dev/null +++ b/pkgs/misc/vim-plugins/vim2nix/autoload/nix.vim @@ -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(':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 = {', + \ ' url = "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': 'git://github.com/'.list[1].'/'.list[2] } + else + let name = list[1] + let repository = { 'type': 'git', 'owner': list[1], 'repo': 'vim-addon-'.list[1], 'url': 'git://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