On 10-09-2022 23:47, Michael Rohleder wrote:
> +           (lambda* (#:key inputs outputs #:allow-other-keys)

'inputs' is unused.

> +             (let* ((out (assoc-ref outputs "out"))
> +                    (completiondir (string-append out "/etc/bash_completion.d")))

#$output can be used nowadays instead of (assoc-ref outputs "out"). 
Then 'outputs' would be unused as well and the lambda can be simplified 
to (lambda _ [...]).

> +               (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))))))))))

Can be simplified to

   (with-output-to-file (string-append completiondir "/ipfs")
     (invoke (string-append out "/bin/ipfs")
             "commands" "completion" "bash"))

(untested)

When cross-compiling, the cross-compiled bin/ipfs cannot be run.  To 
solve this, you can add 'this-package' to the native-inputs conditional 
upon (%current-target-system):

  (native-inputs
     (append
       (if (%current-target-system)
           (list this-package)
           '())
       (list python-minimal-wrapper zsh))).

and in the build phase, do two separate cases: when compiling natively, 
use the ipfs from #$output as you're doing, when cross-compiling, use 
the ipfs from $PATH:

   (with-output-to-file (string-append completiondir "/ipfs")
     (invoke #$(if (%current-target-system)
                   "ipfs"
                   #~(string-append #$output "/bin/ipfs"))
             "commands" "completion" "bash"))

Greetings,
Maxime.