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

Conversation

ersinakinci
Copy link
Contributor

Motivation for this change

Adds vimPlugins.LeaderF so that we can use the wonderful LeaderF plugin for vim.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ersinakinci
Copy link
Contributor Author

I've tried to do as much due diligence as possible. However, I would appreciate it if anyone can answer these questions for me:

  1. Do I need to add myself as a maintainer using overrides.nix?
  2. I inserted a kind of ugly but necessary hack inside of overrides.nix to get Neovim to build correctly. Could someone take a look and let me know if that's acceptable? The hack is only necessary because the $HOME environment variable gets set to /homeless-shelter, which the build process doesn't necessarily have permissions to write to.
  3. I'm not sure how to run nix path-info -S or nix-shell -p nix-review --run "nix-review wip" relative to my new package, which I created inside of a local git repo.

LeaderF = super.LeaderF.overrideAttrs(old: {
buildInputs = [
python3
stdenv
Copy link
Contributor

Choose a reason for hiding this comment

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

stdenv shouldn't be necessary

Suggested change
stdenv
stdenv

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonringer, is there a different way to get gcc? The plugin compiles a C extension.

Copy link
Contributor

@jonringer jonringer Oct 25, 2019

Choose a reason for hiding this comment

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

oh hmmm. I think for the vimplugins they do a { stdenv = stdenvNoCC }.... I'm not actually sure how to get gcc in there again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, it compiled fine for me when I used stdenv 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I just tried it without stdenv and it works fine. I'll remove the dependency. Thanks, @jonringer!

# $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

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.

@Vonfry
Copy link
Member

Vonfry commented Jun 26, 2020

Any updates on this?

@stale
Copy link

stale bot commented Apr 7, 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 Apr 7, 2021
@teto
Copy link
Member

teto commented Jun 24, 2022

seems like LeaderF is packaged already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants