Message ID | 20220706191311.14662-1-antero@mailbox.org |
---|---|
State | Accepted |
Headers | show |
Series | [bug#56428] home: Add -I, --list-installed option. | expand |
Context | Check | Description |
---|---|---|
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | success | View Laminar job |
cbaines/issue | success | View issue |
On 2022-07-06 19:13, Antero Mejr via Guix-patches via wrote: > * guix/scripts/package.scm (list-installed): New procedure. > * guix/scripts/home.scm: Use it. > --- > guix/scripts/home.scm | 13 +++++++++++++ > guix/scripts/package.scm | 30 +++++++++++++++++------------- > 2 files changed, 30 insertions(+), 13 deletions(-) > > diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm > index 0f5c3388a1..7a5078fe3b 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")) > + (newline) > + (display (G_ " > -h, --help display this help and exit")) > (display (G_ " > -V, --version display version information and exit")) > @@ -183,6 +188,14 @@ (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 > + (reverse > + (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..144d18a626 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,21 @@ (define absolute > > (add-indirect-root store absolute)) > > +(define-public (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 > + (($ <manifest-entry> name version output path _) > + (and (regexp-exec regexp name) > + (list name (or version "?") output path)))) > + installed))) > + ;; Show most recently installed packages last. > + (reverse rows))))) > + > > ;;; > ;;; Queries and actions. > @@ -824,19 +840,7 @@ (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))))) > + (pretty-print-table (list-installed regexp profiles)) > #t) > > (('list-available regexp) -I --list-installed works great, thank you. Just a thought for future: Maybe it would be useful to have another option to list all the packages in profile, including propagated.
Andrew Tropin <andrew@trop.in> writes: > -I --list-installed works great, thank you. Just a thought for future: > Maybe it would be useful to have another option to list all the packages > in profile, including propagated. Not sure I fully understand. For example, if a profile's package "foo" has input "bar" and propagated-input "baz": - would you want both "bar" and "baz" listed? - would you want to know the relationships between the packages? Could this could be done with 'guix graph' by adding an ascii backend, like this: guix graph --backend=ascii -t references $(readlink -f \ ~/.guix-home/profile) to get this: +------------+-------+-----------------+------+ | package |parent |type |etc...| +------------+-------+-----------------+------+ | foo |profile|parent | | +------------+-------+-----------------+------+ | bar |foo |input | | +------------+-------+-----------------+------+ | baz |foo |propagated-input | | +------------+-------+-----------------+------+ or this: foo ├── bar (input) └── baz (propagated-input) Maybe a 'guix sbom' subcommand, for "Software Bill of Materials", would be better for displaying lists like this. Having an SBOM exporter would make Guix great for regulated applications like medical device software.
diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 0f5c3388a1..7a5078fe3b 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")) + (newline) + (display (G_ " -h, --help display this help and exit")) (display (G_ " -V, --version display version information and exit")) @@ -183,6 +188,14 @@ (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 + (reverse + (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..144d18a626 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,21 @@ (define absolute (add-indirect-root store absolute)) +(define-public (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 + (($ <manifest-entry> name version output path _) + (and (regexp-exec regexp name) + (list name (or version "?") output path)))) + installed))) + ;; Show most recently installed packages last. + (reverse rows))))) + ;;; ;;; Queries and actions. @@ -824,19 +840,7 @@ (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))))) + (pretty-print-table (list-installed regexp profiles)) #t) (('list-available regexp)