From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yLuGE8rhz2LQVwEAbAwnHQ (envelope-from ) for ; Thu, 14 Jul 2022 11:28:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id YPuaE8rhz2IWCwEA9RJhRA (envelope-from ) for ; Thu, 14 Jul 2022 11:28:42 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B01161D01 for ; Thu, 14 Jul 2022 11:28:41 +0200 (CEST) Received: from localhost ([::1]:34300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBv9E-00023z-MQ for larch@yhetil.org; Thu, 14 Jul 2022 05:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBv2o-0001RV-BT for guix-patches@gnu.org; Thu, 14 Jul 2022 05:22:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oBv2n-0004Xm-Qs for guix-patches@gnu.org; Thu, 14 Jul 2022 05:22:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oBv2n-0001zG-N3 for guix-patches@gnu.org; Thu, 14 Jul 2022 05:22:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56428] [PATCH v3] home: Add -I, --list-installed option. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 14 Jul 2022 09:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56428 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Antero Mejr , 56428@debbugs.gnu.org Received: via spool by 56428-submit@debbugs.gnu.org id=B56428.16577905007604 (code B ref 56428); Thu, 14 Jul 2022 09:22:01 +0000 Received: (at 56428) by debbugs.gnu.org; 14 Jul 2022 09:21:40 +0000 Received: from localhost ([127.0.0.1]:48762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBv2N-0001yW-U1 for submit@debbugs.gnu.org; Thu, 14 Jul 2022 05:21:40 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:53855) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBv2L-0001yG-BV for 56428@debbugs.gnu.org; Thu, 14 Jul 2022 05:21:34 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 5AADD240006; Thu, 14 Jul 2022 09:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1657790486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FbmZy0sxD9suitqhkBnJD0lDTQl8WXSMj2OLyj7IJHQ=; b=mWunrNEPOKA5mnURz51Gcilj9GWVISd8F4yjn6NXmYc9V5F2iUbKGsI4ZU1Q4T2J/PR2AO GxkUQ5OiMUMp1FudHPhf6cyLLxvXdFpcVgKEobpQqaK059EYMyQSkgpor3JeYBqry6tHzb RGKvK1hpMiVpB5zmTWuOOGY5W08g6jjHN3DaSCGhNYnIVSD/KoPYRdlkMuOkYKiZFSenEC UZwC3CT+KKZuaJTjTlQq1hxxCqTNhymBM//aUP2T+0wS9A9StU64MBr7ATj45YytDVvPoD mzKXokCfQ3ju9d46edmcJ98AEgTGb/TceirAtiUL5Tcj1nPJEFoP+Wy5Hktr0g== From: Andrew Tropin In-Reply-To: <20220712225007.23875-1-antero@mailbox.org> References: <20220712225007.23875-1-antero@mailbox.org> Date: Thu, 14 Jul 2022 12:21:23 +0300 Message-ID: <87wncgoxrg.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1657790922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=FbmZy0sxD9suitqhkBnJD0lDTQl8WXSMj2OLyj7IJHQ=; b=MM8PD427koVP4oPN8A0a05SUgkErCTreARJoC6rbfgN7uD96mIXLr715NG6Xzsl6QlIdjv ymz2gPPH2jFrNef/wD+lOJpUutJ4IYnIftWkpQNn+Uwum4mz4UzPQ9vjh1EjDekZVur1Sn tP+iVtpt2IM3JvhyxLp3gPhYcewS7qWCCkmX7bu9FsCV/vahf/s+SaUnJhHI5A0ZPhg6eG 6TqZLRB7kAV4H0TfN7NIq9EMtaAhQD55Y1wBSgkDwAxbrqt3VkkJzDKPNy9v04gKQLW7Q+ JIZ7a5wU7UaZAi5T0Y1q8LhV9JRP0NN44AXDuFHqCttfO4zejZGUvE+r81seCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657790922; a=rsa-sha256; cv=none; b=mx0v+p7Va1t6AKyNfevgOYNo2XL6yoZoP+LIdTvdno9Or42farxOK4M3wXxlG909dbviSF EDcE4+Kb0nVhVH191bBy/gLKauYw5zcvHFOwUm51M7+7FvdP505HYRRm9d/7xJxxzsSeOh VU7BcZHpnJHUmTMpLz5PQYNMse2AYXF+YZScYYZCUrnis8uposVqAKPq2LyEG3weWctR03 5e2UQJ7obyEa7N2DEB/4X2nuarhZqY+xxbLS+Kk6eWZgFXh7i+WlHCjRfrJb67NsAJoXM0 13AthHLojdITeHWaNnzSyVP9W9wciHm2e9s70J5XppaSzLVYz4zy2LDmCQ2KDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=mWunrNEP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.15 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=mWunrNEP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: B01161D01 X-Spam-Score: -1.15 X-Migadu-Scanner: scn1.migadu.com X-TUID: pcgjt27HAbrW --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-07-12 22:50, Antero Mejr wrote: > * guix/scripts/package.scm (list-installed): New procedure. > * guix/scripts/home.scm: Use it. > * guix/scripts/utils.scm (pretty-print-table): New argument "left-pad". > * doc/guix.texi (Invoking Guix Home): Add information and example for > --list-installed flag. > --- > doc/guix.texi | 15 ++++++++++++ > guix/scripts/home.scm | 52 +++++++++++++++++++++++++++++----------- > guix/scripts/package.scm | 31 ++++++++++++++---------- > guix/utils.scm | 4 ++-- > 4 files changed, 73 insertions(+), 29 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 097e4a362b..fc3a2d962d 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -40312,6 +40312,17 @@ install anything. > Describe the current home generation: its file name, as well as > provenance information when available. >=20=20 > +To show installed packages in the current home generation's profile, > +the @code{--list-installed} flag is provided, with the same syntax that > +is used in @command{guix package --list-installed} > +(@pxref{Invoking guix package}). For instance, the following command > +shows a table of all emacs-related packages installed in the > +current home generation's profile, at the end of the description: > + > +@example > +guix home describe --list-installed=3Demacs > +@end example > + > @item list-generations > List a summary of each generation of the home environment available on > disk, in a human-readable way. This is similar to the > @@ -40327,6 +40338,10 @@ generations that are up to 10 days old: > $ guix home list-generations 10d > @end example >=20=20 > +The @code{--list-installed} flag may also be specified, with the same > +syntax that is used in @command{guix home describe}. This may be helpful > +if trying to determine when a package was added to the home profile. > + > @item import > Generate a @dfn{home environment} from the packages in the default > profile and configuration files found in the user's home directory. The > diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm > index 0f5c3388a1..97d626114a 100644 > --- a/guix/scripts/home.scm > +++ b/guix/scripts/home.scm > @@ -4,6 +4,7 @@ > ;;; Copyright =C2=A9 2021 Pierre Langlois > ;;; Copyright =C2=A9 2021 Oleg Pykhalov > ;;; Copyright =C2=A9 2022 Ludovic Court=C3=A8s > +;;; Copyright =C2=A9 2022 Antero Mejr > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -143,6 +144,11 @@ (define (show-help) > use BACKEND for 'extension-graph' and 'shepherd= -graph'")) > (newline) > (display (G_ " > + -I, --list-installed[=3DREGEXP] > + for 'describe' or 'list-generations', list inst= alled > + packages matching REGEXP")) > + (newline) > + (display (G_ " > -h, --help display this help and exit")) > (display (G_ " > -V, --version display version information and exit")) > @@ -183,6 +189,9 @@ (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) > + (alist-cons 'list-installed (or arg "") result))) >=20=20 > ;; Container options. > (option '(#\N "network") #f #f > @@ -569,17 +578,20 @@ (define-syntax-rule (with-store* store exp ...) > deploy the home environment described by these files.\n") > destination)))) > ((describe) > - (match (generation-number %guix-home) > - (0 > - (leave (G_ "no home environment generation, nothing to describe~= %"))) > - (generation > - (display-home-environment-generation generation)))) > + (let ((list-installed-regex (assoc-ref opts 'list-installed))) > + (match (generation-number %guix-home) > + (0 > + (leave (G_ "no home environment generation, nothing to describ= e~%"))) > + (generation > + (display-home-environment-generation > + generation #:list-installed-regex list-installed-regex))))) > ((list-generations) > - (let ((pattern (match args > + (let ((list-installed-regex (assoc-ref opts 'list-installed)) > + (pattern (match args > (() #f) > ((pattern) pattern) > (x (leave (G_ "wrong number of arguments~%")))))) > - (list-generations pattern))) > + (list-generations pattern #:list-installed-regex list-installed-r= egex))) > ((switch-generation) > (let ((pattern (match args > ((pattern) pattern) > @@ -748,7 +760,8 @@ (define (search . args) >=20=20 > (define* (display-home-environment-generation > number > - #:optional (profile %guix-home)) > + #:optional (profile %guix-home) > + #:key (list-installed-regex #f)) > "Display a summary of home-environment generation NUMBER in a > human-readable format." > (define (display-channel channel) > @@ -782,9 +795,16 @@ (define-values (channels config-file) > (format #t (G_ " configuration file: ~a~%") > (if (supports-hyperlinks?) > (file-hyperlink config-file) > - config-file)))))) > - > -(define* (list-generations pattern #:optional (profile %guix-home)) > + config-file))) > + (when list-installed-regex > + (format #t (G_ " packages:\n")) > + (pretty-print-table (list-installed > + list-installed-regex > + (list (string-append generation "/profile")= )) > + #:left-pad 4))))) > + > +(define* (list-generations pattern #:optional (profile %guix-home) > + #:key (list-installed-regex #f)) > "Display in a human-readable format all the home environment > generations matching PATTERN, a string. When PATTERN is #f, display > all the home environment generations." > @@ -792,14 +812,18 @@ (define* (list-generations pattern #:optional (prof= ile %guix-home)) > (raise (condition (&profile-not-found-error > (profile profile))))) > ((not pattern) > - (for-each display-home-environment-generation (profile-generati= ons profile))) > + (for-each (cut display-home-environment-generation <> > + #:list-installed-regex list-installed-regex) > + (profile-generations profile))) > ((matching-generations pattern profile) > =3D> > (lambda (numbers) > (if (null-list? numbers) > (exit 1) > - (leave-on-EPIPE > - (for-each display-home-environment-generation numbers)))= )))) > + (leave-on-EPIPE (for-each > + (cut display-home-environment-generation= <> > + #:list-installed-regex list-install= ed-regex) > + numbers))))))) >=20=20 > > ;;; > diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm > index 99a6cfaa29..af61b50222 100644 > --- a/guix/scripts/package.scm > +++ b/guix/scripts/package.scm > @@ -11,6 +11,7 @@ > ;;; Copyright =C2=A9 2020 Simon Tournier > ;;; Copyright =C2=A9 2018 Steve Sprang > ;;; Copyright =C2=A9 2022 Josselin Poiret > +;;; Copyright =C2=A9 2022 Antero Mejr > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -67,6 +68,7 @@ (define-module (guix scripts package) > delete-generations > delete-matching-generations > guix-package > + list-installed >=20=20 > search-path-environment-variables > manifest-entry-version-prefix > @@ -773,6 +775,20 @@ (define absolute >=20=20 > (add-indirect-root store absolute)) >=20=20 > +(define (list-installed regexp profiles) > + (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 > + (($ name version output path _) > + (and (regexp-exec regexp name) > + (list name (or version "?") output path)))) > + installed))) > + rows)))) > + > > ;;; > ;;; Queries and actions. > @@ -824,19 +840,8 @@ (define (diff-profiles profile numbers) > #t) >=20=20 > (('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 > - (($ 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) >=20=20 > (('list-available regexp) > diff --git a/guix/utils.scm b/guix/utils.scm > index 745da98a79..8484442b29 100644 > --- a/guix/utils.scm > +++ b/guix/utils.scm > @@ -1124,7 +1124,7 @@ (define* (string-closest trial tests #:key (thresho= ld 3)) > ;;; Prettified output. > ;;; >=20=20 > -(define* (pretty-print-table rows #:key (max-column-width 20)) > +(define* (pretty-print-table rows #:key (max-column-width 20) (left-pad = 0)) > "Print ROWS in neat columns. All rows should be lists of strings and = each > row should have the same length. The columns are separated by a tab > character, and aligned using spaces. The maximum width of each column is > @@ -1143,7 +1143,7 @@ (define* (pretty-print-table rows #:key (max-column= -width 20)) > (map (cut min <> max-column-width) > column-widths))) > (fmt (string-append (string-join column-formats "\t") "\t~a"))) > - (for-each (cut format #t "~?~%" fmt <>) rows))) > + (for-each (cut format #t "~v_~?~%" left-pad fmt <>) rows))) >=20=20 > ;;; Local Variables: > ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1) Applied locally, tested, LGTM. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmLP4BMACgkQIgjSCVjB 3rAsZQ/8CZJpU7JY/lUlAynPFp6ZidiNyni5K6GWEC8YVfp2hZNJb5oFYQSnu4Qj nj8hYzWXw3d6Deb31sEUCFeRTgZ1RprMOj86RT3AEWDvM806cO/Px5JG+wASF1zW PhwmD7xZQbUKGSynUAfXipx8zencPzFdtw87lDBui+HyiCp+RzRiR7noefcj9SGQ 5Lw3VWyaRYY4/+145ufFTybBbD+sAKQU2hjnYV1RaiiNl4/2CFn0htTVmKzPPGLZ Dp7vnfE3vpFIjOZCMKOYDjoooHAQi+nEs4qw3MKpH314L1I+7wwPjw1hqD9idKj8 qQpHPGynGW3i2NTUZUAiEP/ArpSjl8OWnGUa/cPPVrCFo3fWGfAcRiDzHxdr/bhh f6pjIAhHjf/lCOlMtbWhaLIXK43EO/4AQ2CMkTk0Us3ShSQOXrVyKJ6Yiqc4gwKr yb1kq0THecBtFl7chPnxu957EtNygT1m9inHwL93ofM2XPonZPfJZRk96GjDrQez RuwLgqgqdZRDRcl0ABDAuOpC9dxD3VNQKPJ4sa6ILnp9XrTfD2q/4twhNLz+6gpU ZMj6BGCsgEyMpzaFk3ic5Tc3xbEDOFyFkMfriQe1voKG+QeQM3bMEDljsSxnVQxF rIGkieE84xe3xD1jYK6WTpnet/cHlyqr948bhT1EozCEt2Z8vNI= =P/kd -----END PGP SIGNATURE----- --=-=-=--