Subject: Re: [bug#56770] [PATCH] gnu: Add grimshot.

From: Maxime Devos <[email-masked]>
Date: Tue, 26 Jul 2022 17:46:20 +0200

> +          (copy-recursively
> +           (string-append #$(package-source this-package) "/contrib") ".")
I would have expected trivial-build-system to automatically unpack the 
source, so maybe this can be simplified to (chdir "/contrib") (untested!)

On 25-07-2022 22:54, Antero Mejr via Guix-patches via wrote:
> +          (system
> +           (string-append #$scdoc "/bin/scdoc < grimshot.1.scd > grimshot.1"))

This ignores any errors coming from 'system'. Try (invoke ...) + 
with-input-from-file + with-output-to-file instead, which will report 
errors as exceptions:

(with-input-from-file "grimshot.1.scd"
   (lambda ()
     (with-output-to-file "grimshot.1"
       (lambda ()
         (invoke #+(file-append (this-package-native-input "scdoc") 
"/bin/scdoc")))))

Here it is important to use #+ instead of #$ for cross-compilation.  I 
use this-package-native-input here to make the --with-input 
transformation work.

> +          (substitute* "grimshot"
> +            (("date ") (string-append #$coreutils "/bin/date "))
> +            (("jq ") (string-append #$jq "/bin/jq "))
> +            (("swaymsg ") (string-append #$sway "/bin/swaymsg "))
> +            (("notify-send ") (string-append #$libnotify "/bin/notify-send "))
> +            (("grim ") (string-append #$grim "/bin/grim "))
> +            (("slurp ") (string-append #$slurp "/bin/slurp "))
> +            (("wl-copy ") (string-append #$wl-clipboard "/bin/wl-copy ")))
Likewise, you should use this-package-input here (but unlike the 
previous case, not this-package-native-input).

(I only looked at the package definition, not the underlying source 
code, and did not test it)

Greetings,
Maxime