Whenever we create scripts that are installed to $out, we must use runtimeShell
in order to get the shell that can be executed on the machine we create the
package for. This is relevant for cross-compiling. The only use case for
stdenv.shell are scripts that are executed as part of the build system.
Usages in checkPhase are borderline however to decrease the likelyhood
of people copying the wrong examples, I decided to use runtimeShell as well.
The fzf vim plugin wasn't working because it was making a symlink to a
directory with the full source code. This directory isn't present
anymore since the commit e95f17e272 wich
removes it because it isn't so useful for the go packages.
I fixed it by manually copying the plugin/ directory into the out
derivation, which is the only part of the source that contains the vim
plugin.
During patch phase, the path to the fzf binary is overwritten in the vim
plugin source. The sed expression doing this wasn't working because the fzf
code changed in this commit:
02ceae15a2
making the patch useless.
I fixed it and added a check to verify that the plugin was effecively
patched to prevent this to happen in the future.
So that helper scripts can be easily sourced in interactive shell
configuration. `autojump` package was already present and had the same
requirements for findind a `share` folders, so I took an inspiration
there.
I beleive this is a better alternative to:
- https://github.com/NixOS/nixpkgs/pull/25080
- https://github.com/NixOS/nixpkgs/pull/27058
Replacing `$out/share/shell` with `$bin/share/fzf` was necessary to
prevent dependency loop in produced derivations.