nixpkgs/pkgs/tools/misc/fzf/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.7 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, buildGoModule
, fetchFromGitHub
, writeShellScriptBin
, runtimeShell
, installShellFiles
, ncurses
, perl
, glibcLocales
, testers
, fzf
}:
let
# on Linux, wrap perl in the bash completion scripts with the glibc locales,
# so that using the shell completion (ctrl+r, etc) doesn't result in ugly
# warnings on non-nixos machines
ourPerl = if !stdenv.isLinux then perl else (
writeShellScriptBin "perl" ''
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
exec ${perl}/bin/perl "$@"
'');
in
2019-07-10 16:36:06 +00:00
buildGoModule rec {
pname = "fzf";
version = "0.39.0";
src = fetchFromGitHub {
owner = "junegunn";
2019-07-10 16:36:06 +00:00
repo = pname;
rev = version;
hash = "sha256-YEysMybjxWwvoX5wMphOZsXw1lV5XqPsp9+Q9V/8cAs=";
};
vendorHash = "sha256-yycwi7SLNmUnpsoP6QBXizVbibh/wEYZb1OqigLFJqs=";
2019-07-10 16:36:06 +00:00
outputs = [ "out" "man" ];
2017-01-06 09:27:35 +00:00
nativeBuildInputs = [ installShellFiles ];
2017-04-03 23:30:08 +00:00
buildInputs = [ ncurses ];
2021-07-31 13:44:18 +00:00
ldflags = [
"-s" "-w" "-X main.version=${version} -X main.revision=${src.rev}"
];
# The vim plugin expects a relative path to the binary; patch it to abspath.
postPatch = ''
sed -i -e "s|expand('<sfile>:h:h')|'$out'|" plugin/fzf.vim
if ! grep -q $out plugin/fzf.vim; then
echo "Failed to replace vim base_dir path with $out"
exit 1
fi
2020-08-21 20:30:27 +00:00
# Has a sneaky dependency on perl
# Include first args to make sure we're patching the right thing
substituteInPlace shell/key-bindings.bash \
--replace " perl -n " " ${ourPerl}/bin/perl -n "
'';
2016-09-14 20:29:08 +00:00
postInstall = ''
install bin/fzf-tmux $out/bin
installManPage man/man1/fzf.1 man/man1/fzf-tmux.1
2019-07-10 16:36:06 +00:00
install -D plugin/* -t $out/share/vim-plugins/${pname}/plugin
2023-03-05 16:49:18 +00:00
mkdir -p $out/share/nvim
ln -s $out/share/vim-plugins/${pname} $out/share/nvim/site
# Install shell integrations
install -D shell/* -t $out/share/fzf/
install -D shell/key-bindings.fish $out/share/fish/vendor_functions.d/fzf_key_bindings.fish
mkdir -p $out/share/fish/vendor_conf.d
echo fzf_key_bindings > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
2019-07-10 16:36:06 +00:00
cat <<SCRIPT > $out/bin/fzf-share
#!${runtimeShell}
# Run this script to find the fzf shared folder where all the shell
# integration scripts are living.
2019-07-10 16:36:06 +00:00
echo $out/share/fzf
SCRIPT
2019-07-10 16:36:06 +00:00
chmod +x $out/bin/fzf-share
'';
2016-07-18 04:36:35 +00:00
passthru.tests.version = testers.testVersion {
package = fzf;
};
2019-07-10 16:36:06 +00:00
meta = with lib; {
homepage = "https://github.com/junegunn/fzf";
2016-07-18 04:36:35 +00:00
description = "A command-line fuzzy finder written in Go";
license = licenses.mit;
maintainers = with maintainers; [ Br1ght0ne ma27 zowoq ];
2016-07-18 04:36:35 +00:00
platforms = platforms.unix;
2021-03-13 23:39:18 +00:00
changelog = "https://github.com/junegunn/fzf/blob/${version}/CHANGELOG.md";
2016-07-18 04:36:35 +00:00
};
2020-06-08 03:24:35 +00:00
}