unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Antero Mejr <antero@mailbox.org>, 56770@debbugs.gnu.org
Subject: [bug#56770] [PATCH v2] gnu: Add grimshot.
Date: Tue, 26 Jul 2022 20:29:53 +0200	[thread overview]
Message-ID: <d1c80c34-ec0b-44d8-79cc-406cd5c6c559@telenet.be> (raw)
In-Reply-To: <20220726175817.422441-1-antero@mailbox.org>


[-- Attachment #1.1.1: Type: text/plain, Size: 3187 bytes --]


On 26-07-2022 19:58, Antero Mejr wrote:
> * gnu/packages/wm.scm (grimshot): New variable.
> ---
> changes for v2:
> 1. using copy-build-system instead of trivial-build-system because it is
> simpler, copy-build-system handles unpacking the source
Now that you are using copy-build-system, using phases, the 
'this-package-input' can be changed to something more robust ...
> +(define-public grimshot
> +  (package
> +    (inherit sway)
> +    (name "grimshot")
> +    (source (origin
> +              (inherit (package-source sway))
> +              (snippet #~(begin
> +                           (delete-file "contrib/grimshot.1")))))
Some people have a preference for writing #~(begin [a single 
invocation]) anyway, but I'd like to note that wrapping the delete-file 
in a (begin ...) is not technically required.
> +    (build-system copy-build-system)
> +    (arguments
> +     (list #:install-plan #~`(("grimshot" "bin/")
> +                              ("grimshot.1" "usr/share/man/man1/"))
> +           #:phases #~(modify-phases %standard-phases
> +                        (add-after 'unpack 'chdir
> +                          (lambda _
> +                            (chdir "contrib")))
> +                        (add-after 'chdir 'patch-script-deps
No need to abbreviate dependencies -> deps, not that it matters much I 
suppose.
> +                          (lambda _
> +                            (substitute* "grimshot"
> +                              (("date ")
> +                               (string-append #$(this-package-input "coreutils")
> +                                              "/bin/date "))

Now that this is written as a phase, it becomes possible to use 
'search-input-file', like this:

> (lambda* (#:key inputs #:allow-other-keys)
>   (substitute*
>     (("\\b(date|jq|swaymsg|...)\\b" _ binary)
>      (search-input-file inputs (string-append "bin/" binary)))))
>
This way, you are not referring to input labels anymore, which has as 
benefit that package transformations become more robust. E.g., if you do 
it this way instead of using input labels (which this-package-input) 
does, it becomes possible to do things like 
--with-input=coreutils=busybox or the Scheme equivalent.
> +                        (add-after 'patch-script-deps 'build-man-page
> +                          (lambda _
> +                            (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")))))))))))

'invoke' does not need the absolute file name, so you the #+(file-append 
...) can be simplified to just "scdoc": [all the surrounding 
with-input/output-...+lambda (invoke "scdoc")], 'invoke' will 
automatically figure out the absolute file name.

Greetings,
Maxime.


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  parent reply	other threads:[~2022-07-26 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 20:54 [bug#56770] [PATCH] gnu: Add grimshot Antero Mejr via Guix-patches via
2022-07-26 15:46 ` Maxime Devos
2022-07-26 15:52   ` Maxime Devos
2022-07-26 15:49 ` Maxime Devos
2022-07-26 17:58 ` [bug#56770] [PATCH v2] " Antero Mejr via Guix-patches via
2022-07-26 18:17   ` Maxime Devos
2022-07-26 18:29   ` Maxime Devos [this message]
2022-07-26 20:48 ` [bug#56770] [PATCH v3] " Antero Mejr via Guix-patches via
2022-07-26 22:06   ` [bug#56770] LGTM: [PATCH v3] gnu: Add grimshot. (LGTM) Maxime Devos
2022-07-27 18:42     ` bug#56770: " Liliana Marie Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1c80c34-ec0b-44d8-79cc-406cd5c6c559@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=56770@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).