Michael Rohleder wrote 3 years ago
(address . guix-patches@gnu.org)(name . Michael Rohleder)(address . mike@rohleder.de)
* gnu/packages/ipfs.scm (ipfs)[arguments]: Add 'install-bashcompletion
phase to install bash completion.
---
gnu/packages/ipfs.scm | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
Toggle diff (43 lines)
diff --git a/gnu/packages/ipfs.scm b/gnu/packages/ipfs.scm
index ccc36007b4..faa209bf2a 100644
--- a/gnu/packages/ipfs.scm
+++ b/gnu/packages/ipfs.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
-;;; Copyright © 2020, 2021 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2020, 2021, 2022 Michael Rohleder <mike@rohleder.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -230,7 +230,26 @@ (define-public go-ipfs
(build-system go-build-system)
(arguments
`(#:unpack-path "github.com/ipfs/go-ipfs"
- #:import-path "github.com/ipfs/go-ipfs/cmd/ipfs"))
+ #:import-path "github.com/ipfs/go-ipfs/cmd/ipfs"
+ #:modules ((guix build utils)
+ (guix build go-build-system)
+ (ice-9 popen)
+ (ice-9 textual-ports))
+ #:phases
+ (modify-phases %standard-phases
+ ;; https://github.com/ipfs/kubo/blob/master/docs/command-completion.md
+ (add-after 'install 'install-bashcompletion
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (completiondir (string-append out "/etc/bash_completion.d")))
+ (mkdir-p completiondir)
+ (call-with-output-file (string-append completiondir "/ipfs")
+ (lambda (port)
+ (let ((input-pipe (open-pipe* OPEN_READ
+ (string-append out "/bin/ipfs")
+ "commands" "completion" "bash")))
+ (display (get-string-all input-pipe) port)
+ (close-pipe input-pipe))))))))))
(native-inputs
(list python-minimal-wrapper zsh))
(home-page "https://ipfs.io")
--
2.37.3