diff mbox series

[bug#41260,1/1] guix package: Support multiple profiles with '--list-installed'.

Message ID 20200514141759.6455-1-zimon.toutoune@gmail.com
State Accepted
Headers show
Series Support multiple profiles with '--list-installed'. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Simon Tournier May 14, 2020, 2:17 p.m. UTC
* guix/scripts/package.scm (process-query): List installed multiple profiles.
---
 guix/scripts/package.scm | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

Comments

Ludovic Courtès May 16, 2020, 5:33 p.m. UTC | #1
Hi!

zimoun <zimon.toutoune@gmail.com> skribis:

> * guix/scripts/package.scm (process-query): List installed multiple profiles.

[...]

> +       (for-each
> +        (lambda (profile)
> +          (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
> +                 (manifest  (profile-manifest profile))
> +                 (installed (manifest-entries manifest)))
> +            (leave-on-EPIPE
> +             (for-each (match-lambda
> +                         (($ <manifest-entry> name version output path _)
> +                          (when (or (not regexp)
> +                                    (regexp-exec regexp name))
> +                            (format #t "~a\t~a\t~a\t~a~%"
> +                                    name (or version "?") output path))))
> +
> +                       ;; Show most recently installed packages last.
> +                       (reverse installed)))))
> +        profiles)

How about instead loading all the manifests, merging them with
‘concatenate-manifests’, and operating on that?  That would avoid
special-casing.

Bonus point if you can add a test case for that, similar to
‘--search-paths’ with multiple profiles.  :-)

Thanks,
Ludo’.
Simon Tournier May 21, 2020, 9:43 p.m. UTC | #2
Hi Ludo,

Sorry for the delay.

On Sat, 16 May 2020 at 19:34, Ludovic Courtès <ludo@gnu.org> wrote:

> How about instead loading all the manifests, merging them with
> ‘concatenate-manifests’, and operating on that?  That would avoid
> special-casing.

See v2.


> Bonus point if you can add a test case for that, similar to
> ‘--search-paths’ with multiple profiles.  :-)

Done in 'tests/guix-packages-net.sh'.  See v2.


BTW, I added a 'delete-duplicates' on profiles.  And I was tempted to
also add 'sort' to always process in the same order.  And personally,
I prefer the alphanumerical order than the order of installation
because it is more reliable and easier to find what I am looking for
-- otherwise I always do the extra step of pipe: |cut -f1| xargs echo|
sort which is "ugly".  The order of installation seems redundant with
--list-generation.  WDYT?


Cheers,
simon
Ludovic Courtès May 22, 2020, 8:31 p.m. UTC | #3
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> BTW, I added a 'delete-duplicates' on profiles.  And I was tempted to
> also add 'sort' to always process in the same order.  And personally,
> I prefer the alphanumerical order than the order of installation
> because it is more reliable and easier to find what I am looking for
> -- otherwise I always do the extra step of pipe: |cut -f1| xargs echo|
> sort which is "ugly".  The order of installation seems redundant with
> --list-generation.  WDYT?

I’m not sure about ‘sort’ because the order (unfortunately) does make a
difference when there are file-level collisions.  If we were starting
today, we could forcefully sort things, but I’m tempted to think that
it’d break someone’s workflow if we did it now¹.

Ludo’.

¹ Obligatory reference: <https://xkcd.com/1172/>.
Simon Tournier May 25, 2020, 9:32 a.m. UTC | #4
Hi Ludo,

On Fri, 22 May 2020 at 22:31, Ludovic Courtès <ludo@gnu.org> wrote:

> ¹ Obligatory reference: <https://xkcd.com/1172/>.

Yeah! Exactly! :-)
But I feel one "formatter" to "pretty" display is lacking.  It should
be an elegant solution for the recent discussion, a bit as "git log
--pretty=oneline|full|etc." does.
For example, I remember an old (rejected) patch by Robert Vollmer [1].

[1] https://lists.gnu.org/archive/html/guix-devel/2019-07/msg00304.html

Anyway, another topic. :-)


Thank you for the review.
All the best,
simon
diff mbox series

Patch

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a69efa365e..a4a6100a33 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -717,20 +717,23 @@  processed, #f otherwise."
        #t)
 
       (('list-installed regexp)
-       (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
-              (manifest  (profile-manifest profile))
-              (installed (manifest-entries manifest)))
-         (leave-on-EPIPE
-          (for-each (match-lambda
-                      (($ <manifest-entry> name version output path _)
-                       (when (or (not regexp)
-                                 (regexp-exec regexp name))
-                         (format #t "~a\t~a\t~a\t~a~%"
-                                 name (or version "?") output path))))
-
-                    ;; Show most recently installed packages last.
-                    (reverse installed)))
-         #t))
+       (for-each
+        (lambda (profile)
+          (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
+                 (manifest  (profile-manifest profile))
+                 (installed (manifest-entries manifest)))
+            (leave-on-EPIPE
+             (for-each (match-lambda
+                         (($ <manifest-entry> name version output path _)
+                          (when (or (not regexp)
+                                    (regexp-exec regexp name))
+                            (format #t "~a\t~a\t~a\t~a~%"
+                                    name (or version "?") output path))))
+
+                       ;; Show most recently installed packages last.
+                       (reverse installed)))))
+        profiles)
+       #t)
 
       (('list-available regexp)
        (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))