1{ stdenv, ncurses, buildGoPackage, fetchFromGitHub, writeText }:
2
3buildGoPackage rec {
4 name = "fzf-${version}";
5 version = "0.17.4";
6 rev = "${version}";
7
8 goPackagePath = "github.com/junegunn/fzf";
9
10 src = fetchFromGitHub {
11 inherit rev;
12 owner = "junegunn";
13 repo = "fzf";
14 sha256 = "10k21v9x82imly36lgra8a7rlvz5a1jd49db16g9xc11wx7cdg8g";
15 };
16
17 outputs = [ "bin" "out" "man" ];
18
19 fishHook = writeText "load-fzf-keybindings.fish" "fzf_key_bindings";
20
21 buildInputs = [ ncurses ];
22
23 goDeps = ./deps.nix;
24
25 patchPhase = ''
26 sed -i -e "s|expand('<sfile>:h:h')|'$bin'|" plugin/fzf.vim
27
28 # Original and output files can't be the same
29 if cmp -s $src/plugin/fzf.vim plugin/fzf.vim; then
30 echo "Vim plugin patch not applied properly. Aborting" && \
31 exit 1
32 fi
33 '';
34
35 preInstall = ''
36 mkdir -p $bin/share/fish/vendor_functions.d $bin/share/fish/vendor_conf.d
37 cp $src/shell/key-bindings.fish $bin/share/fish/vendor_functions.d/fzf_key_bindings.fish
38 cp ${fishHook} $bin/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
39 '';
40
41 postInstall = ''
42 cp $src/bin/fzf-tmux $bin/bin
43 mkdir -p $man/share/man
44 cp -r $src/man/man1 $man/share/man
45 mkdir -p $out/share/vim-plugins/${name}
46 cp -r $src/plugin $out/share/vim-plugins/${name}
47
48 cp -R $src/shell $bin/share/fzf
49 cat <<SCRIPT > $bin/bin/fzf-share
50 #!/bin/sh
51 # Run this script to find the fzf shared folder where all the shell
52 # integration scripts are living.
53 echo $bin/share/fzf
54 SCRIPT
55 chmod +x $bin/bin/fzf-share
56 '';
57
58 meta = with stdenv.lib; {
59 homepage = https://github.com/junegunn/fzf;
60 description = "A command-line fuzzy finder written in Go";
61 license = licenses.mit;
62 platforms = platforms.unix;
63 };
64}