Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim-addon-nix seems to no longer work with neovim #54585

Closed
nagisa opened this issue Jan 25, 2019 · 39 comments
Closed

vim-addon-nix seems to no longer work with neovim #54585

nagisa opened this issue Jan 25, 2019 · 39 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@nagisa
Copy link
Contributor

nagisa commented Jan 25, 2019

Issue description

My vim.nix looks like this:

{ config, pkgs, ... }:
{
  nixpkgs.config.packageOverrides = old: {
    neovim = old.neovim.override {
      vimAlias = true;
      configure = {
        vam = {
          knownPlugins = pkgs.vimPlugins // ({
            solarized8 = pkgs.vimUtils.buildVimPluginFrom2Nix {
              name = "vim-solarized8";
              src = pkgs.fetchgit {
                url = "git://github.com/lifepillar/vim-solarized8";
                rev = "dc6c1dfa6f5c068ba338b8a2e4f88f4b6de4433a";
                sha256 = "1r7hm0v2hck6rpcs2gmj4cc3ziw5bkhvq1ngc84b2pscvpmdqlia";
              };
              dependencies = [];
            };

            matchmaker = pkgs.vimUtils.buildVimPluginFrom2Nix {
              name = "vim-matchmaker";
              src = pkgs.fetchgit {
                url = "git://github.com/qstrahl/vim-matchmaker";
                rev = "f606f58aa1dbc2c948b5277f18e92b41ae82ead5";
                sha256 = "155vpcld1ibmqw1nwjdl0pafwbc5vl2fp4sxfzvzhbbg1g7c21pc";
              };
              dependencies = [];
            };
          });

          # There's a list of available plugins here:
          # https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/vim-plugins/vim-plugin-names
          pluginDictionaries = [
            { name = "ctrlp"; }
            { name = "rust-vim"; }
            { name = "solarized8"; }
            { name = "matchmaker"; }
#            { name = "vim-addon-nix"; }
          ];
        };
        customRC = ''
            " snip...
        '';
      };
    };
  };
}

if vim-addon-nix is uncommented, the build fails with the following error:

building '/nix/store/dfqwlmbhp1dlhkbkinl6ls66mv58dvak-neovim-0.3.4.drv'...
Generating remote plugin manifest
Plugin: vim-pi
Home page: https://bitbucket.org/vimcommunity/vim-pi
Source URL: https://bitbucket.org/vimcommunity/vim-pi/get/master.tar.bz2 (type archive)
name: 'vim-pi'
archive_name: 'vim-pi.tar.gz'
Target: /homeless-shelter/.vim/vim-addons/vim-pi
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[7]..vam#install#CompleteRepoData[10]..vam#install#LoadPool[4]..vam#install#Pool[1]..vam#install#LoadKnownRepos[20]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[48]..vam#install#Checkout:
line   14:
E739: Cannot create directory /homeless-shelter: permission denied
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[7]..vam#install#CompleteRepoData[10]..vam#install#LoadPool[4]..vam#install#Pool:
line    2:
E117: Unknown function: vam_known_repositories#Pool
E15: Invalid expression: vam_known_repositories#Pool()
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[7]..vam#install#CompleteRepoData[10]..vam#install#LoadPool:
line    7:
E715: Dictionary required
E714: List required
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[7]..vam#install#CompleteRepoData:
line   12:
E712: Argument of get() must be a List or Dictionary
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[21]..vam#DisplayAddonInfoLines:
line   11:
E716: Key not present in Dictionary: url =~? '^\w\+://github\.com/'
E15: Invalid expression: repository.url =~? '^\w\+://github\.com/'
line   16:
E716: Key not present in Dictionary: url.' (type '.get(repository, 'type', 'archive').')',)
E116: Invalid arguments for function add
Plugin: tlib
name: 'tlib'
Target: /homeless-shelter/.vim/vim-addons/tlib
Dependency chain: tlib < vim-addon-completion < vim-addon-nix
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[48]..vam#install#Checkout[8]..vam#vcs#Checkout:
line    1:
E716: Key not present in Dictionary: type)
E116: Invalid arguments for function has_key
E15: Invalid expression: has_key(s:c.scms, a:repository.type)
line   11:
E605: Exception not caught: Failure. Plugin directory /homeless-shelter/.vim/vim-addons/tlib should have been created but does not exist.
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install[48]..vam#install#Checkout:
line    8:
E171: Missing :endif
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[30]..vam#install#Install:
line   48:
E171: Missing :endif
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively:
line   30:
E171: Missing :endif
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively:
line   36:
E171: Missing :endif
Error detected while processing function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively:
line   36:
E171: Missing :endif
remote/host: generated rplugin manifest: /nix/store/ww6zah1qzf2fqilwjg7d2dyxq1jkr5c2-neovim-0.3.4/rplugin.vim
Generating rplugin.vim failed!
builder for '/nix/store/dfqwlmbhp1dlhkbkinl6ls66mv58dvak-neovim-0.3.4.drv' failed with exit code 1

It appears that something is incompatible/broken in the vim-addon-nix addon. It used to work until just recently.

Steps to reproduce

The configuration file is described above. Import it into configuration.nix and try to build system that is dependent on neovim.

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.18.10, NixOS, 19.03pre153894.a1935724197 (Koi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.2`
 - channels(root): `"nixos-19.03pre167359.ba9d958adfc"`
 - channels(nagisa): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@symphorien
Copy link
Member

probably linked to #53084
cc @timokau
It seems that since you use vam, some plugins try to write to $HOME when generating the rplugin manifest and this fails.

@timokau
Copy link
Member

timokau commented Jan 26, 2019

Do you have any idea why it would try to write to $HOME?

@nagisa
Copy link
Contributor Author

nagisa commented Jan 26, 2019

Sadly, no idea. I never configured vim-addon-nix in any way.

All I know is that the issue started occuring within past 2 or so months (that’s when I last successfully managed to update my system with vim-addon-nix plugin enabled).

@symphorien
Copy link
Member

Do you have any idea why it would try to write to $HOME?

Source URL: https://bitbucket.org/vimcommunity/vim-pi/get/master.tar.bz2 (type archive)
name: 'vim-pi'
archive_name: 'vim-pi.tar.gz'
Target: /homeless-shelter/.vim/vim-addons/vim-pi

this suggests vam is installing all missing plugins (in $HOME)
If this is the case, I don't understand how it could work if you comment vim-addon-nix. You still have three plugins vam would install.

Maybe vam plugin installation should be disabled when generating rplugins manifest ?

@timokau
Copy link
Member

timokau commented Jan 26, 2019

I'm not sure why its doing that anyways. Does it just do that on every startup without any user input? Seems like that would slow down startup significantly.

@symphorien
Copy link
Member

Apparently the nix/vam instrumentation installs things at each startup

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 about which plugins to load when:
let l = []
${lib.concatMapStrings (p: "call add(l, ${toNix p})\n") vam.pluginDictionaries}
call vam#Scripts(l, {})

Honestly, I have a hard time understanding what happens here.

@timokau
Copy link
Member

timokau commented Jan 26, 2019

The simple, stupid solution would be to just do export HOME=$TMPDIR. That should work. It'll generate some unnecessary files, but as long as it also generates the remote manifest that should be fine.

@symphorien
Copy link
Member

It also attempts to download missing plugins and the vim-pi repo in the sandbox...

@timokau
Copy link
Member

timokau commented Jan 27, 2019

Weird. I thought the point of managing plugins through nix was that plugins are fetched by nix.

@kamilchm
Copy link
Member

kamilchm commented Feb 1, 2019

What is the easiest solution to have working neovim now?

The simple, stupid solution would be to just do export HOME=$TMPDIR.

@timokau where do I need to put this?

@nagisa
Copy link
Contributor Author

nagisa commented Feb 1, 2019

What is the easiest solution to have working neovim now?

I ended up commenting out offending plugins. vim-addon-nix is by no means critical to me.

@timokau
Copy link
Member

timokau commented Feb 1, 2019

I have no idea how to fix this, I don't know enough about VAM and don't want to spend too much time reading up on it. If neovim startup fails without internet access, that looks like a bug to me.

Should we just skip rplugin generation when using vam? @MarcWeber maybe you have an opinion.

@MarcWeber
Copy link
Contributor

I recommend git bisect to see what broke it.

VAM uses vim-pi (vim package index) to install packages.
But it should not be related to nix other than there was a viml function getting dependencies out of vim-pi writing hackish .nix file contents.

neovim has some code to generate interface .vim files or such (commands/mappings lazy load stuff).
And it looks like the code above eventually runs and generates such. I don't use neovim much.

vim-addon-nix eventually pulls some dependencies such "dependencies" : { "vim-addon-mw-utils": {}, "tlib": {}, "vim-addon-actions": {}, "vim-addon-completion": {}, "vim-addon-goto-thing-at-cursor": {}, "vim-addon-errorformats": {} },

which also could cause the failure. But I don't see how they are related to the derivation
All those plugins are simple plugins basically archives without code to be executed.

let nixkgs = import <nixpkgs> {};
in nixpkgs.neovim

put such in ./test.nix then run nix-build ./default.nix and use git bisect.

If missing HOME is the problem then just mkdir -p fake-home. export HOME=pwd/fake-home in a setup hook and retry. This would be most simple.

@timokau
Copy link
Member

timokau commented Feb 1, 2019

We know what caused this: It was me adding the functionality of generating the remote-plugin manifest in #53084.

So we now start neovim once during build (with the plugin RC) to generate the remote plugin manifest. That fails with vam because it tries to go online for some reason.

@timokau
Copy link
Member

timokau commented Feb 2, 2019

If nobody is willing to look into how to make the rplugin manifest generation work with VAM (I'm not), we can simply make sure the failure doesn't break the build.

In that case vam plugins would work as before, while other plugin mechanisms could make use of the rplugin manifest generation.

@MarcWeber
Copy link
Contributor

The only reason why VAM goes online is missing dependencies.
If it wants to download a plugin because a plugin requests it (eg by addon-info.json)
then it downloads vim-pi to and the plugin. vim-pi maps a plugin name a to repository source.
In rare cases some additional post hooks are defined.

So I suggest removing all plugins, trying to build the plugin with VAM only to see whether it works, then adding one plugin after the next to find out which one is missing dependencies / source.

The vimrc nix implementation manually registers plugins and nix store paths to make VAM avoid downloading the plugins.

In my personal case it looks like this:
https://mawercer.de/tmp/tmp/sample.vim

@MarcWeber
Copy link
Contributor

Plugin: vim-pi and and Target: .. lines are generated by plugin info and installation code from VAM.
Generating remote plugin manifest -> this line does not belong to VAM.
So debugging should be as easy as manually running the build phase and looking what vimrc getsn passed to Vim and seeing what plugins/dependencies are causing the installation phase to start.
@nagisa Do you know how to do this ? There is nix-build --keep-failed then look at env-vars file at /tmp or nix-shell see here https://nixos.wiki/wiki/Nixpkgs/Create_and_debug_packages#Using_nix-shell_for_package_development

@timokau
Copy link
Member

timokau commented Feb 2, 2019

So the issue is probably that vim-plugin-nix has some dependencies that aren't declared in its nix derivation? And then vam just goes looking for it on its own?

It would be nice to have a way to tell vam not to do that. Instead it should hard-fail, giving an error message that a dependency couldn't be satisfied.

@timokau
Copy link
Member

timokau commented Feb 2, 2019

Yes the "Generating remote plugin manifest" line is where neovim gets started with a vimrc containing the plugin configuration (basically the final vimrc minus the customRC part) and generates the rplugin manifest.

@nagisa
Copy link
Contributor Author

nagisa commented Feb 2, 2019

@MarcWeber

env_vars
declare -x AR="ar"
declare -x AS="as"
declare -x CC="gcc"
declare -x CONFIG_SHELL="/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash"
declare -x CXX="g++"
declare -x HOME="/homeless-shelter"
declare -x HOST_PATH="/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin:/nix/store/5c2428hk25dwsgnifcmn5dvgrwvvgvrx-findutils-4.6.0/bin:/nix/store/xfhxxapsygwz6k74nkikc1sp6yga6z59-diffutils-3.7/bin:/nix/store/4lvbww6zrphadhcbqidx8qskc0rsblg6-gnused-4.7/bin:/nix/store/f7c1ijdv5czqb0dxi4mi5wkfvi1pc7rn-gnugrep-3.3/bin:/nix/store/9jjxqhwak78zi94m7gvwdw3gqzd1hr1b-gawk-4.2.1/bin:/nix/store/6y95ihqqw5ws23mp74f919d5q49jin9l-gnutar-1.30/bin:/nix/store/i4m1hzhb1axvliw6qbn9mllj4dqb46kg-gzip-1.10/bin:/nix/store/jq5xf3914l56w1dlsdlsza76b782sdkj-bzip2-1.0.6.0.1-bin/bin:/nix/store/nj0aq4p4m55ci500x1flh8v2cc6snwh7-gnumake-4.2.1/bin:/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin:/nix/store/fbhgrqka1ld7n3njahrgpsi1rajpif69-patch-2.7.6/bin:/nix/store/q54svsx75b23y8n5l55zvj2cmcihgrdk-xz-5.2.4-bin/bin"
declare -x LD="ld"
declare -x NIX_BINTOOLS="/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30"
declare -x NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST="1"
declare -x NIX_BUILD_CORES="16"
declare -x NIX_BUILD_TOP="/build"
declare -x NIX_CC="/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0"
declare -x NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST="1"
declare -x NIX_ENFORCE_NO_NATIVE="1"
declare -x NIX_ENFORCE_PURITY="1"
declare -x NIX_HARDENING_ENABLE="fortify stackprotector pic strictoverflow format relro bindnow"
declare -x NIX_INDENT_MAKE="1"
declare -x NIX_LDFLAGS="-rpath /nix/store/nd4q43icw42skl4j4lpcx84wql1jcsga-neovim-0.3.4/lib64 -rpath /nix/store/nd4q43icw42skl4j4lpcx84wql1jcsga-neovim-0.3.4/lib "
declare -x NIX_LOG_FD="2"
declare -x NIX_STORE="/nix/store"
declare -x NM="nm"
declare -x OBJCOPY="objcopy"
declare -x OBJDUMP="objdump"
declare -x OLDPWD
declare -x PATH="/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9/bin:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0/bin:/nix/store/4ga86h16l157r7bas9hcwxgl9d3r32s6-gcc-7.4.0/bin:/nix/store/rjsymbdxlwmfbpasn0jik1w97wgfk3qj-glibc-2.27-bin/bin:/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30/bin:/nix/store/3xwc1ip20b0p68sxqbjjll0va4pv5hbv-binutils-2.30/bin:/nix/store/rjsymbdxlwmfbpasn0jik1w97wgfk3qj-glibc-2.27-bin/bin:/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin:/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin:/nix/store/5c2428hk25dwsgnifcmn5dvgrwvvgvrx-findutils-4.6.0/bin:/nix/store/xfhxxapsygwz6k74nkikc1sp6yga6z59-diffutils-3.7/bin:/nix/store/4lvbww6zrphadhcbqidx8qskc0rsblg6-gnused-4.7/bin:/nix/store/f7c1ijdv5czqb0dxi4mi5wkfvi1pc7rn-gnugrep-3.3/bin:/nix/store/9jjxqhwak78zi94m7gvwdw3gqzd1hr1b-gawk-4.2.1/bin:/nix/store/6y95ihqqw5ws23mp74f919d5q49jin9l-gnutar-1.30/bin:/nix/store/i4m1hzhb1axvliw6qbn9mllj4dqb46kg-gzip-1.10/bin:/nix/store/jq5xf3914l56w1dlsdlsza76b782sdkj-bzip2-1.0.6.0.1-bin/bin:/nix/store/nj0aq4p4m55ci500x1flh8v2cc6snwh7-gnumake-4.2.1/bin:/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin:/nix/store/fbhgrqka1ld7n3njahrgpsi1rajpif69-patch-2.7.6/bin:/nix/store/q54svsx75b23y8n5l55zvj2cmcihgrdk-xz-5.2.4-bin/bin"
declare -x PWD="/build"
declare -x RANLIB="ranlib"
declare -x READELF="readelf"
declare -x SHELL="/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash"
declare -x SHLVL="1"
declare -x SIZE="size"
declare -x SOURCE_DATE_EPOCH="1"
declare -x SSL_CERT_FILE="/no-cert-file.crt"
declare -x STRINGS="strings"
declare -x STRIP="strip"
declare -x TEMP="/build"
declare -x TEMPDIR="/build"
declare -x TMP="/build"
declare -x TMPDIR="/build"
declare -x TZ="UTC"
declare -x _PATH="/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9/bin:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0/bin:/nix/store/4ga86h16l157r7bas9hcwxgl9d3r32s6-gcc-7.4.0/bin:/nix/store/rjsymbdxlwmfbpasn0jik1w97wgfk3qj-glibc-2.27-bin/bin:/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30/bin:/nix/store/3xwc1ip20b0p68sxqbjjll0va4pv5hbv-binutils-2.30/bin:/nix/store/rjsymbdxlwmfbpasn0jik1w97wgfk3qj-glibc-2.27-bin/bin:/nix/store/lvhndwdy2q09fhwgzykjjigz7yxq5yiv-coreutils-8.30/bin"
declare -x buildCommand="if [ ! -x \"/nix/store/qfac63crw2dcfsv25fk39q9n08cxzw3y-neovim-unwrapped-0.3.4/bin/nvim\" ]
then
    echo \"cannot find executable file \\\`/nix/store/qfac63crw2dcfsv25fk39q9n08cxzw3y-neovim-unwrapped-0.3.4/bin/nvim'\"
    exit 1
fi

makeWrapper \"\$(readlink -v --canonicalize-existing \"/nix/store/qfac63crw2dcfsv25fk39q9n08cxzw3y-neovim-unwrapped-0.3.4/bin/nvim\")\" \\
  \"\$out/bin/nvim\" --add-flags \" \\
--cmd \\\"let g:loaded_node_provider=1\\\" \\
--cmd \\\"let g:python_host_prog='\$out/bin/nvim-python'\\\" \\
--cmd \\\"let g:python3_host_prog='\$out/bin/nvim-python3'\\\" \\
--cmd \\\"let g:ruby_host_prog='\$out/bin/nvim-ruby'\\\" \" \\
--suffix PATH : /nix/store/r1y3jnzsl1ywmfv5js9ba8wif8zw5q4x-neovim-ruby-env/bin \\
--set GEM_HOME /nix/store/r1y3jnzsl1ywmfv5js9ba8wif8zw5q4x-neovim-ruby-env/lib/ruby/gems/2.5.0
# copy and patch the original neovim.desktop file
mkdir -p \$out/share/applications
substitute /nix/store/qfac63crw2dcfsv25fk39q9n08cxzw3y-neovim-unwrapped-0.3.4/share/applications/nvim.desktop \$out/share/applications/nvim.desktop \\
  --replace 'TryExec=nvim' \"TryExec=\$out/bin/nvim\" \\
  --replace 'Name=Neovim' 'Name=WrappedNeovim'
makeWrapper /nix/store/7bds2hh4majqz8x90izvbx79czdq6gs6-python-2.7.15-env/bin/python \$out/bin/nvim-python --unset PYTHONPATH
makeWrapper /nix/store/dg3bkgkhmk2bgn8mb13xjn0i7k9sr7v9-python3-3.7.2-env/bin/python3 \$out/bin/nvim-python3 --unset PYTHONPATH
ln -s /nix/store/r1y3jnzsl1ywmfv5js9ba8wif8zw5q4x-neovim-ruby-env/bin/neovim-ruby-host \$out/bin/nvim-ruby
ln -s \$out/bin/nvim \$out/bin/vim
echo \"Generating remote plugin manifest\"
export NVIM_RPLUGIN_MANIFEST=\$out/rplugin.vim
# Launch neovim with a vimrc file containing only the generated plugin
# code. Pass various flags to disable temp file generation
# (swap/viminfo) and redirect errors to stderr.
# Only display the log on error since it will contain a few normally
# irrelevant messages.
if ! \$out/bin/nvim \\
  -u /nix/store/phrvqh8r3hxr2rys95xfb36v6cyv3gbg-vimrc \\
  -i NONE -n \\
  -E -V1rplugins.log -s \\
  +UpdateRemotePlugins +quit! > outfile 2>&1; then
  cat outfile
  echo -e \"\\nGenerating rplugin.vim failed!\"
  exit 1
fi
unset NVIM_RPLUGIN_MANIFEST

# this relies on a patched neovim, see
# https://github.com/neovim/neovim/issues/9413
wrapProgram \$out/bin/nvim \\
  --set NVIM_SYSTEM_RPLUGIN_MANIFEST \$out/rplugin.vim \\
  --add-flags \"-u /nix/store/jf6m2w0fqca4119h4klwv56sbayyzi73-vimrc\"
"
declare -x buildInputs="/nix/store/25ri300myxzi2lqyxs2y2ciwb0q0gl4g-hook"
declare -x builder="/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash"
declare -x configureFlags=""
declare -x depsBuildBuild=""
declare -x depsBuildBuildPropagated=""
declare -x depsBuildTarget=""
declare -x depsBuildTargetPropagated=""
declare -x depsHostHost=""
declare -x depsHostHostPropagated=""
declare -x depsTargetTarget=""
declare -x depsTargetTargetPropagated=""
declare -x doCheck=""
declare -x doInstallCheck=""
declare -x name="neovim-0.3.4"
declare -x nativeBuildInputs=""
declare -x out="/nix/store/nd4q43icw42skl4j4lpcx84wql1jcsga-neovim-0.3.4"
declare -x outputs="out"
declare -x preferLocalBuild="1"
declare -x propagatedBuildInputs=""
declare -x propagatedNativeBuildInputs=""
declare -x shell="/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash"
declare -x stdenv="/nix/store/yax21ms90cwr2l4rygd60wfbpfwg5hip-stdenv-linux"
declare -x strictDeps=""
declare -x system="x86_64-linux"
/nix/store/jf6m2w0fqca4119h4klwv56sbayyzi73-vimrc
" minimal setup, generated by NIX
set nocompatible

let g:nix_plugin_locations = {}
let g:nix_plugin_locations['ctrlp'] = "/nix/store/q5ixw86ij2fdc0mz73sazy8q09qdil86-vimplugin-ctrlp-vim-2018-11-22/share/vim-plugins/ctrlp-vim"
let g:nix_plugin_locations['rust-vim'] = "/nix/store/v0idm4bqzprlqaxd2f83pgq9izjp5wyk-vimplugin-rust-vim-2019-01-01/share/vim-plugins/rust-vim"
let g:nix_plugin_locations['solarized8'] = "/nix/store/lz6pg4b37zwln2j1ig3f2135w5y2vsg3-vimplugin-vim-solarized8/share/vim-plugins/vim-solarized8"
let g:nix_plugin_locations['matchmaker'] = "/nix/store/kyggxl530673faf0anpr5nbl117sdp17-vimplugin-vim-matchmaker/share/vim-plugins/vim-matchmaker"
let g:nix_plugin_locations['vim-addon-nix'] = "/nix/store/23ayk1bkvix3xscmfd3samb9avyhh44p-vimplugin-vim-addon-nix-2017-09-11/share/vim-plugins/vim-addon-nix"
let g:nix_plugin_locations['vim-addon-completion'] = "/nix/store/8dy2nbv10gl8cs8jgfjn70w6xlpiim7n-vimplugin-vim-addon-completion-2015-02-10/share/vim-plugins/vim-addon-completion"
let g:nix_plugin_locations['vim-addon-goto-thing-at-cursor'] = "/nix/store/2zrfbi47hwda5j6i383w46hk1cb7yn4r-vimplugin-vim-addon-goto-thing-at-cursor-2018-12-28/share/vim-plugins/vim-addon-goto-thing-at-cursor"
let g:nix_plugin_locations['vim-addon-errorformats'] = "/nix/store/izg2nicphs04x0fpvdal7apk9vi4ly9v-vimplugin-vim-addon-errorformats-2014-11-05/share/vim-plugins/vim-addon-errorformats"
let g:nix_plugin_locations['vim-addon-actions'] = "/nix/store/bj1yqaw3cmq00jf7b185mk5y32kgmghm-vimplugin-vim-addon-actions-2018-01-18/share/vim-plugins/vim-addon-actions"
let g:nix_plugin_locations['vim-addon-mw-utils'] = "/nix/store/gaa8cixzx384vmsc5wwxhca43hxzk25r-vimplugin-vim-addon-mw-utils-2018-03-09/share/vim-plugins/vim-addon-mw-utils"
let g:nix_plugin_locations['tlib_vim'] = "/nix/store/isy9rjwhhiymz94fvy1saj86i91sq08d-vimplugin-tlib_vim-2018-04-08/share/vim-plugins/tlib_vim"

let g:nix_plugin_locations['vim-addon-manager'] = "/nix/store/pdm01a3vvzqnnfkfp3kqnraxw8lzw3ql-vimplugin-vim-addon-manager-2018-07-27/share/vim-plugins/vim-addon-manager"

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 about which plugins to load when:
let l = []
call add(l, {'name': 'ctrlp'})
call add(l, {'name': 'rust-vim'})
call add(l, {'name': 'solarized8'})
call add(l, {'name': 'matchmaker'})
call add(l, {'name': 'vim-addon-nix'})

call vam#Scripts(l, {})







filetype indent plugin on | syn on

@MarcWeber
Copy link
Contributor

https://github.com/MarcWeber/vim-addon-vim2nix This is the tool I wrote back then honoring dependencies.
I lost scope. If people mix and match things now ..
Yes of course we can patch the install routine adding a hard failure saying 'dependency X not found.

its trivial -> The .vimrc I showed has a function tilling VAM about the location of a plugin. If it doesn't exist echoe and make vim exit with exit code ?
https://stackoverflow.com/questions/43113569/how-to-close-vim-editor-with-non-zero-return-value

https://mawercer.de/tmp/tmp/sample.vim
-> Vim plugin location

However after installing :ActivateAddon allows laziy installing plugins and make it work.
So maybe we should also test for /homless-shelter to exist or $out to understand whether its a nix build?

Thus if $out != "" && plugin_not_registerered then show error?

@MarcWeber
Copy link
Contributor

@nagisa Do you think the hints I gave are enough to try such patch to understand whether VAM is missing a dependency and which one ?
Also try dropping all plugins and see whether it fails l succeeds then.

@timokau
Copy link
Member

timokau commented Feb 2, 2019

"Failure only during nix build" is basically what is happening now, just without a nice error message.

I think the ideal would be if only plugins registered by nix would refuse automatic dependency resolution. So some way of telling vam "I know what I'm doing by registering this plugin, if it doesn't look right to you I messed up". That way users can still do whatever they want in their own vimrcs, but we can guarantee that plugins provided by nixpkgs work as they should without any need to install anything at runtime.

@nagisa
Copy link
Contributor Author

nagisa commented Feb 2, 2019

Do you think the hints I gave are enough to try such patch to understand whether VAM is missing a dependency and which one ?

I am not sufficiently knowledgeable about the vim plugin operation or nix packaging to attempt that As I said before, vim-addon-nix is the least valuable plugin for me by far and I’m fine with just not having it at all.

I’ll gladly try trivial modifications and/or commands (such as the --keep-failed above) to assist you in figuring the issue out, in case you are unable/unwilling to reproduce the issue yourselves.

@MarcWeber
Copy link
Contributor

I looked at the code and found that VAM already says everything which is required:

Dependency chain: tlib < vim-addon-completion < vim-addon-nix

So the problem is the name missmatch 'vim_tlib' vs tlib.

vim-pi meant to be a 'package name index' for vim packages - but not many people joined.
So either we have to rename 'vim_tlib' to 'tlib' in nix or 'tlib' to 'vim_tlib' in the dependency files.

@MarcWeber
Copy link
Contributor

vim-addon-nix does syntax checking and follows import lines by pressing gf. Maybe there are some more features, by I love them that's why I wrote it. Maybe it still contains syntax. That time I wrote it it was best I could do.

The main problem is than Bram never cared about community setting up standards.
A lot of duplicated work was done by all parties involved. But that's another story.

@MarcWeber
Copy link
Contributor

I guess the features of vim-addon-nix should be split into individual repositories (syntax vs gf vs syntax checker) and it should be made optional
@nagisa: All I asked for replacing this function in nixpkgs and testing it:

  fun! NixPluginLocation(name)
    let path = get(g:nix_plugin_locations, a:name, "")
    if $out != "" && path == ""
      echoe "plugin ".a:name." cannot be found in nix_plugin_locations. Look for 'Dependency chain' in log to understand why it is required. This error is contained in ".expand('<sfile>')
      cq!
    endif
    let path == "" ? vam#DefaultPluginDirFromName(a:name) : path
    return path
  endfun

```

@kamilchm
Copy link
Member

kamilchm commented Feb 6, 2019

plugin tlib cannot be found in nix_plugin_locations. Look for 'Dependency chain' in log to understand why it is required. This error is contained in function vam#Scripts[22]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[36]..vam#ActivateDependencies[4]..vam#ActivateAddons[59]..vam#ActivateRecursively[21]..vam#PluginDirFromName[1]..NixPluginLocation

and there's no Dependency chain in the logs.

I fixed it in my vim config by adding tlib as separate plugin kamilchm/.nixpkgs@6eb7af9

@srid
Copy link
Contributor

srid commented Feb 25, 2020

I also see this with https://github.com/alok/notational-fzf-vim

@cideM
Copy link
Contributor

cideM commented Jul 14, 2020

Same with https://github.com/neovim/nvim-lsp/ see this issue

I don't have any in depth knowledge of Nix but my 2 cents would be that starting Neovim for the build might not be a good idea in the long run. Many plugins will want to create folders, often for good reasons and following XDG best practices. But right now these plugins can then never be loaded for start and only for opt, which might be acceptable in certain cases but is not really a good overall solution.

Maybe it's worth revisiting if the manifest generation is worth keeping #54585 (comment) because it seems to me that a few more manual steps would be better than the current status

@timokau
Copy link
Member

timokau commented Jul 14, 2020

Creating folders alone shouldn't be much of a problem, we could just point HOME to a writable tmpdir. If that would solve a problem you're having, feel free to open a PR for that and ping me. (Also wow, that issue's author is giving a horrible impression of the nix community).

@cideM
Copy link
Contributor

cideM commented Jul 14, 2020

In my case the issue is solved by simply having nvim-lsp as an opt plugin. Since the rplugin generation uses a special config file that plugin is then not loaded since :packadd is never called. So it's all good for me actually 🎊

And yes, the issue author seemed to be having a particularly terrible day.

@timokau
Copy link
Member

timokau commented Jul 14, 2020

Since the rplugin generation uses a special config file that plugin is then not loaded since :packadd is never called.

That actually sounds like a bug in the manifest generation 😄. If someone fixes the HOME issue, we might want to fix that as well.

@cideM
Copy link
Contributor

cideM commented Jul 14, 2020

Huh I see I interpreted this code and the added comment

# Launch neovim with a vimrc file containing only the generated plugin
# code.

to mean that my own customRC (containing :packadd nvim-lsp) wouldn't be active here

@timokau
Copy link
Member

timokau commented Jul 14, 2020

Yes, but its still unexpected behaviour that opt plugins do not get manifests. We should either move all plugins to startup or inject the packadd commands for the manifest generation.

@hydn10
Copy link

hydn10 commented Jul 20, 2020

I am very inexperienced in all this, so maybe i mixing things up, but isn't HOME already being set to a temp dir here?
This is the commit that adds the line, from some months ago.

I was having the same problem you were mentioning with nvim-lsp, but I am on branch nixos-20.03 where this commit is not applied.

@timokau
Copy link
Member

timokau commented Jul 20, 2020

You're right, apparently the issue is already fixed on master. I think it would be fine to backport this to latest stable if someone wants to open a PR.

@stale
Copy link

stale bot commented Jan 17, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 17, 2021
@timokau
Copy link
Member

timokau commented Jan 18, 2021

The fix should now be in the latest stable release (20.09) as well. I think this is resolved. If you still encounter issues, please leave a comment or reopen.

@timokau timokau closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

8 participants