NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.15k stars 13.42k forks source link

vim_configurable: custom buildInputs not on PATH #41613

Open ariutta opened 6 years ago

ariutta commented 6 years ago

Issue description

Maintainer: @lovek323

I want my version of vim_configurable to use Neoformat. Neoformat sends buffer data via stdin to formatters like shfmt. This requires that the formatters be added to the PATH.

When adding one or more formatters as buildInputs via vim_configurable.overrideAttrs, the formatters are not added to the PATH. That means Neoformat cannot use them.

(Possibly related to #34340.)

Steps to reproduce

Install a version of vim_configurable with a custom buildInput, e.g.:

with import <nixpkgs> { config.allowUnfree = true; };
pkgs.vim_configurable.overrideAttrs (oldAttrs: {
  # NOTE: we don't need to specify the following:
  #   with import <nixpkgs> { config.vim.ftNix = false; };
  # because we specify the same thing here:
  ftNixSupport = false;
  buildInputs = pkgs.vim_configurable.buildInputs ++ [ pkgs.shfmt ];
})

Expected: shfmt is on the PATH Actual: it's not

Technical details

LnL7 commented 6 years ago

Adding buildInputs is build time only, these won't automatically become available at runtime. Support for python modules was added in https://github.com/NixOS/nixpkgs/pull/40920, maybe we should generalise that to also support extra binaries.

ariutta commented 6 years ago

Is that specific to this package? Regarding buildInputs, the docs say:

These often are programs/libraries used by the new derivation at run-time...

ariutta commented 6 years ago

Also, I think I did try all of the different options (buildInputs, propagatedBuildInputs, etc.).

Ma27 commented 6 years ago

I worked around this for the python dependency in #40920, not sure if we want to implement this for all build inputs though.

ariutta commented 6 years ago

In general, I agree that adding dependencies to the path is bad. We want to avoid side effects.

But for shfmt, I'm only using it in Vim, and it's not a python dependency. It's clumsy to specify shfmt as a dependency anywhere other than the Nix expression for my custom Vim configuration.

ariutta commented 6 years ago

How about setting $PATH in .vimrc? The dependency paths can be managed in default.nix. This way, Vim/Neoformat/Syntastic can still talk to the CLI tools, but they aren't added to $PATH outside Vim.

timokau commented 5 years ago

It would be possible to add support for this to the vim infrastructure, but I feel like most of the time dependencies on CLI tools are soft dependencies. You can manually add them by adding lines like this to customRC:

let $PATH .= ':${pkgs.python3.pkgs.pyflakes}/bin:${pkgs.python3.pkgs.pylint}/bin'
stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.