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

vimPlugins.LeaderF: init at 2019-10-15 #71972

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkgs/misc/vim-plugins/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,17 @@ let
};
};

LeaderF = buildVimPluginFrom2Nix {
pname = "LeaderF";
version = "2019-10-15";
src = fetchFromGitHub {
owner = "Yggdroot";
repo = "LeaderF";
rev = "00af3cd7d2648a0e11f7220f6df1a1d790d2fbe1";
sha256 = "11kfhpfzkcsm0df5rkmhbf22d8y1kq26x3gr84zb7pn4pail7nca";
};
};

lean-vim = buildVimPluginFrom2Nix {
pname = "lean-vim";
version = "2017-05-03";
Expand Down
23 changes: 23 additions & 0 deletions pkgs/misc/vim-plugins/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ self: super: {
meta.maintainers = with stdenv.lib.maintainers; [ minijackson ];
};

LeaderF = super.LeaderF.overrideAttrs(old: {
buildInputs = [
python3
];
buildPhase = ''
patchShebangs .
export PY3=ON
./install.sh
'';
# HACK: Installing this plugin triggers Vim/Neovim to reload along with
# this plugin, which triggers autoload/lfMru.vim to load, which in turn
# attempts to read the g:Lf_CacheDirectory setting. That setting is set to
# $HOME, which during the build points to the non-existent
# /homeless-shelter. lfMru.vim tries to create the directory but lacks
# sufficient permissions, so this code forces g:Lf_CacheDirectory to point
# to $TMPDIR only when $HOME == /homeless-shelter, i.e., only during builds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this. When and why is $HOME accessed?

Copy link
Contributor Author

@ersinakinci ersinakinci Oct 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timokau, $HOME is accessed here when trying to get the g:Lf_CacheDirectory setting in vim: https://github.com/Yggdroot/LeaderF/blob/v1.21/autoload/lfMru.vim#L10. The default for that setting is $HOME, which is set to /homeless-shelter during the build.

A few lines later, the script attempts to create the directory pointed to by g:Lf_CacheDirectory if it doesn't already exist: https://github.com/Yggdroot/LeaderF/blob/v1.21/autoload/lfMru.vim#L13. This action sometimes fails during the build because the user often doesn't have permission to create /homeless-shelter. I assume that it would work if running as root, but we need to account for non-root users.

Besides, in this case, there isn't really a need to ensure that the cache directory exists. The error occurs when attempting to build neovim (and would probably affect vim builds, I assume, but I haven't checked) and the plugin is installed. The error doesn't occur when trying to build this plugin. That's because the the invalid access occurs in the autoload script for the plugin. The plugin is simply being loaded during the course of opening neovim while neovim is being built, which triggers the autoload script, which in turn triggers the mkdir that results in a permission error (when building as a non-privileged user). Therefore, we don't actually need the cache dir because the error is being triggered when the plugin isn't really being used for anything; it serves no purpose in this context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that sounds like the remote manifest generation is the issue. Neovim is launched with a minimal vimrc (that just includes the plugins) during build to generate the remote plugin manifest.

If that is the case, other plugins are likely to have similar issues. Maybe it would be better to create a home directory for the manifest generation. Could you try adding export HOME="$(mktemp -d)" before the manifest generation in pkgs/applications/editors/neovim/wrapper.nix? Please also add a short comment that explains why it is necessary.

Copy link
Member

@felschr felschr Feb 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fyi, the export HOME fix was used in #72506 which appears to be close to being merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felschr, correct 🙂. I will clean up this PR and ask for this to be merged once #72506 gets merged.

preFixup = ''
substituteInPlace "$out"/share/vim-plugins/LeaderF/autoload/lfMru.vim \
--replace "let g:Lf_CacheDirectory = substitute(g:Lf_CacheDirectory, '[\/]$', ''', ''')" \
"if g:Lf_CacheDirectory == '/homeless-shelter' ''\n let g:Lf_CacheDirectory = '$TMPDIR' ''\nendif''\n''\nlet g:Lf_CacheDirectory = substitute(g:Lf_CacheDirectory, '[\/]$', ''', ''')"
'';
});

meson = buildVimPluginFrom2Nix {
inherit (meson) pname version src;
preInstall = "cd data/syntax-highlighting/vim";
Expand Down
1 change: 1 addition & 0 deletions pkgs/misc/vim-plugins/vim-plugin-names
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ xolox/vim-easytags
xolox/vim-misc
xuhdev/vim-latex-live-preview
Yggdroot/indentLine
Yggdroot/LeaderF
zah/nim.vim
zchee/deoplete-clang
zchee/deoplete-go
Expand Down