From: Andrew Tropin <andrew@trop.in>
To: Antero Mejr <antero@mailbox.org>, 56428@debbugs.gnu.org
Subject: [bug#56428] [PATCH] home: Add -I, --list-installed option.
Date: Tue, 12 Jul 2022 13:13:57 +0300 [thread overview]
Message-ID: <87o7xu1vve.fsf@trop.in> (raw)
In-Reply-To: <20220707150644.2349-1-antero@mailbox.org>
[-- Attachment #1: Type: text/plain, Size: 5619 bytes --]
On 2022-07-07 15:06, Antero Mejr via Guix-patches via wrote:
Hi Antero,
this is a good addition, thank you very much!
A hint: use reroll-count when generating new revision of the patch and
subject will become [PATCH v2], [PATCH v3] etc.
> * guix/scripts/package.scm (list-installed): New procedure.
> * guix/scripts/home.scm: Use it.
> ---
> Remove extra (reverse...) from last patch.
>
> guix/scripts/home.scm | 12 ++++++++++++
> guix/scripts/package.scm | 30 +++++++++++++++++-------------
> 2 files changed, 29 insertions(+), 13 deletions(-)
>
> diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm
> index 0f5c3388a1..b0b8412d8c 100644
> --- a/guix/scripts/home.scm
> +++ b/guix/scripts/home.scm
> @@ -4,6 +4,7 @@
> ;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
> ;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
> ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
> +;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -143,6 +144,10 @@ (define (show-help)
> use BACKEND for 'extension-graph' and 'shepherd-graph'"))
> (newline)
> (display (G_ "
> + -I, --list-installed[=REGEXP]
> + list installed packages matching REGEXP"))
1. guix home/system and guix package has slightly different cli:
guix package --list-generations vs guix home/system list-generations
I think that later is more apropriate, because:
`guix package --remove=htop --list-installed` is possible, but doesn't
make too much sense, and `guix home reconfigure ./he.scm list-installed`
is not possible, because only one action at time can be specicified.
Implementing this functionality as --argument makes it possible to type
`guix home reconfigure ./he.scm --list-installed`, which again doesn't
make much sense as in the example above. I advice either implement
list-installed as a separate action or as an additional --argument to
describe/list-generations action.
2. Would be good to mention it in doc/guix.texi.
3. It would be nice to implement the same for guix system.
> + (newline)
> + (display (G_ "
> -h, --help display this help and exit"))
> (display (G_ "
> -V, --version display version information and exit"))
> @@ -183,6 +188,13 @@ (define %options
> (option '("graph-backend") #t #f
> (lambda (opt name arg result)
> (alist-cons 'graph-backend arg result)))
> + (option '(#\I "list-installed") #f #t
> + (lambda (opt name arg result)
> + (pretty-print-table
> + (list-installed (or arg "")
> + (list
> + (string-append %guix-home "/profile"))))
> + (exit 0)))
>
> ;; Container options. (option '(#\N "network") #f #f diff
> --git a/guix/scripts/package.scm b/guix/scripts/package.scm index
> 99a6cfaa29..02e91a0ee1 100644 --- a/guix/scripts/package.scm +++
> b/guix/scripts/package.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020
> Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2018 Steve
> Sprang <scs@stevesprang.com> ;;; Copyright © 2022 Josselin Poiret
> <dev@jpoiret.xyz> +;;; Copyright © 2022 Antero Mejr
> <antero@mailbox.org> ;;; ;;; This file is part of GNU Guix. ;;; @@
> -773,6 +774,20 @@ (define absolute
>
> (add-indirect-root store absolute))
>
> +(define-public (list-installed regexp profiles)
To make it consistent with the rest of the module, I think it will
better to use define and explicitly export list-installed in module
definition at the top of the file.
> + (let* ((regexp (and regexp (make-regexp* regexp regexp/icase)))
> + (manifest (concatenate-manifests
> + (map profile-manifest profiles)))
> + (installed (manifest-entries manifest)))
> + (leave-on-EPIPE
> + (let ((rows (filter-map
> + (match-lambda
> + (($ <manifest-entry> name version output path _)
> + (and (regexp-exec regexp name)
> + (list name (or version "?") output path))))
> + installed)))
> + rows))))
> +
> \f
> ;;;
> ;;; Queries and actions.
> @@ -824,19 +839,8 @@ (define (diff-profiles profile numbers)
> #t)
>
> (('list-installed regexp)
> - (let* ((regexp (and regexp (make-regexp* regexp regexp/icase)))
> - (manifest (concatenate-manifests
> - (map profile-manifest profiles)))
> - (installed (manifest-entries manifest)))
> - (leave-on-EPIPE
> - (let ((rows (filter-map
> - (match-lambda
> - (($ <manifest-entry> name version output path _)
> - (and (regexp-exec regexp name)
> - (list name (or version "?") output path))))
> - installed)))
> - ;; Show most recently installed packages last.
> - (pretty-print-table (reverse rows)))))
> + ;; Show most recently installed packages last.
> + (pretty-print-table (reverse (list-installed regexp profiles)))
> #t)
>
> (('list-available regexp)
Tested the patch, guix package -I, guix home -I filter-regex works good,
but see my comments above.
--
Best regards,
Andrew Tropin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2022-07-12 10:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 19:13 [bug#56428] [PATCH] home: Add -I, --list-installed option Antero Mejr via Guix-patches via
2022-07-07 15:06 ` Antero Mejr via Guix-patches via
2022-07-12 10:13 ` Andrew Tropin [this message]
2022-07-12 22:50 ` Antero Mejr via Guix-patches via
2022-07-12 22:50 ` [bug#56428] [PATCH v3] " Antero Mejr via Guix-patches via
2022-07-14 9:21 ` Andrew Tropin
2022-07-18 13:21 ` bug#56428: [PATCH] " Ludovic Courtès
2022-08-05 6:12 ` [bug#56428] " Andrew Tropin
2022-08-06 23:02 ` Antero Mejr via Guix-patches via
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7xu1vve.fsf@trop.in \
--to=andrew@trop.in \
--cc=56428@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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.