Subject: [PATCH 1/2] gnu: go-github-com-junegunn-fzf: Copy binaries and install shell completions.

From: EuAndreh <[email-masked]>
Date: Mon, 18 Jan 2021 16:04:58 -0300

* gnu/packages/terminals.scm (go-github-com-junegunn-fzf)[arguments]: Add
  copy-binaries, wrap-programs and install-completion phases.
---
 gnu/packages/terminals.scm | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index 74e1937bbc..308ff99bf0 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -813,7 +813,33 @@ programmer to write text-based user interfaces.")
          "0n0cy5q2r3dm1a3ivlzrv9c5d11awxlqim5b9x8zc85dlr73n35l"))))
     (build-system go-build-system)
     (arguments
-     `(#:import-path "github.com/junegunn/fzf"))
+     `(#:import-path "github.com/junegunn/fzf"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'copy-binaries
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (with-directory-excursion "src/github.com/junegunn/fzf"
+                 (install-file "bin/fzf-tmux"
+                               (string-append out "/bin"))))))
+         (add-after 'copy-binaries 'wrap-programs
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (ncurses (assoc-ref inputs "ncurses")))
+               (wrap-program (string-append out "/bin/fzf-tmux")
+                 `("PATH" ":" prefix (,(string-append ncurses "/bin")))))))
+         (add-after 'install 'install-completions
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bash-completion (string-append out "/etc/bash_completion.d"))
+                    (zsh-completion (string-append out "/share/zsh/site-functions")))
+               (with-directory-excursion "src/github.com/junegunn/fzf"
+                 (mkdir-p bash-completion)
+                 (copy-file "shell/completion.bash"
+                            (string-append bash-completion "/fzf"))
+                 (mkdir-p zsh-completion)
+                 (copy-file "shell/completion.zsh"
+                            (string-append zsh-completion "/_fzf")))))))))
     (inputs
      `(("go-github.com-mattn-go-runewidth" ,go-github.com-mattn-go-runewidth)
        ("go-github-com-mattn-go-shellwords" ,go-github-com-mattn-go-shellwords)
@@ -821,7 +847,8 @@ programmer to write text-based user interfaces.")
        ("go-github-com-gdamore-tcell" ,go-github-com-gdamore-tcell)
        ("go-github-com-saracen-walker" ,go-github-com-saracen-walker)
        ("go-golang.org-x-sync-errgroup" ,go-golang.org-x-sync-errgroup)
-       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
+       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+       ("ncurses" ,ncurses)))
     (home-page "https://github.com/junegunn/fzf")
     (synopsis "Command-line fuzzy-finder")
     (description "This package provides an interactive command-line filter
-- 
2.30.0