[PATCH] ui: Describe package outputs.

DoneSubmitted by Liliana Marie Prikler.
Details
4 participants
  • Leo Famulari
  • Liliana Marie Prikler
  • Ludovic Courtès
  • Maxime Devos
Owner
unassigned
Severity
normal
L
L
Liliana Marie Prikler wrote on 18 Mar 20:16 +0100
(address . guix-patches@gnu.org)
cf9713d087089126b1f8b9102cb8f37a879fa6fd.camel@gmail.com
* guix/ui.scm (package->recutils): Output outputs with their descriptions,
one per line.
---
Salut Guix,

People have been complaining for a while, that outputs are not really
discoverable [who?]. This patch attempts to fix that by displaying each
on their own line with a (hopefully) helpful description next to it.
It is expected, that these descriptions do not span multiple lines.

Cheers

guix/ui.scm | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

Toggle diff (49 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index 6c194eb3c9..dfa90126bc 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2018 Steve Sprang <scs@stevesprang.com>
+;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1543,13 +1544,33 @@ (define (dependencies->recutils packages)
                                    (sort packages package<?))) " ")))
       (split-lines list (string-length "dependencies: "))))
 
+  (define (output->recutils package output)
+    (let ((descs (assq-ref (package-properties package) 'output-descriptions)))
+      (string-append
+       "+ " output ": "
+       (or
+        (assoc-ref descs output)
+        (assoc-ref `(("bin" . ,(G_ "executable programs and scripts."))
+                     ("debug" . ,(G_ "debug information."))
+                     ("lib" . ,(G_ "shared libraries."))
+                     ("static" . ,(G_ "static libraries."))
+                     ("out" . ,(G_ "everything else.")))
+                   output)
+        (G_ "state secrets.")))))
+
+  (define (package-outputs/out-last package)
+    ((compose append partition)
+     (negate (cut string=? "out" <>))
+     (package-outputs package)))
+
   (define (package<? p1 p2)
     (string<? (package-full-name p1) (package-full-name p2)))
 
   ;; Note: Don't i18n field names so that people can post-process it.
   (format port "name: ~a~%" (package-name p))
   (format port "version: ~a~%" (package-version p))
-  (format port "outputs: ~a~%" (string-join (package-outputs p)))
+  (format port "outputs:~%~{~a~%~}"
+          (map (cut output->recutils p <>) (package-outputs/out-last p)))
   (format port "systems: ~a~%"
           (split-lines (string-join (package-transitive-supported-systems p))
                        (string-length "systems: ")))
-- 
2.34.0
M
M
Maxime Devos wrote on 18 Mar 21:12 +0100
a0839f706b22f010f4d3988421ee524edaf727fe.camel@telenet.be
Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
Toggle quote (6 lines)
> +        (assoc-ref `(("bin" . ,(G_ "executable programs and scripts."))
> +                     ("debug" . ,(G_ "debug information."))
> +                     ("lib" . ,(G_ "shared libraries."))
> +                     ("static" . ,(G_ "static libraries."))
> +                     ("out" . ,(G_ "everything else.")))

Some other outputs in the wild: "python", "utils", "xpi", "firefox",
"chromium", "gui", "doc", "drill", "examples", "pyldns", "nm", "gtk2",
"gtk3", "gtk4", "module", "src", "woff2", "headless", "installer",
"jdk", "qt", "tester", "pulseaudio", "jack", "image", "opt-viewer",
"examples", "metis", "cargo".

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjTnyRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gVvAQDj1KwF2sfXUSxxMvIBiHVhIkNJ
wS/bqo6ComQgXvs+wQD8DEcw367FCEsHUzsSQwJFg77v5XthapUfTPleRUZfoAM=
=H5xg
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 18 Mar 21:16 +0100
dfeccaf27d201c708588b8599067eb4f75ee6c12.camel@telenet.be
Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
Toggle quote (2 lines)
> +        (G_ "state secrets.")))))

Wouldn't this require #:substitutable? #false?
It's punny but rather inaccurate ...
WDYT of adding a package property to allow packages to document unusual
outputs?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjTomhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gvfAQDYHLWO/s+KXhUnOQECq/ah6sBO
a1+ZV5ATouSNmow9ngEA09jZM1KVEoTLkY47CrZWvWJWwYV51PBEkiMttzkhKQY=
=MrTl
-----END PGP SIGNATURE-----


L
L
Liliana Marie Prikler wrote on 18 Mar 21:23 +0100
9ca3d2474ff8469f537f0351b0fdfb99e80940fe.camel@gmail.com
Am Freitag, dem 18.03.2022 um 21:12 +0100 schrieb Maxime Devos:
Toggle quote (14 lines)
> Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
> > +        (assoc-ref `(("bin" . ,(G_ "executable programs and
> > scripts."))
> > +                     ("debug" . ,(G_ "debug information."))
> > +                     ("lib" . ,(G_ "shared libraries."))
> > +                     ("static" . ,(G_ "static libraries."))
> > +                     ("out" . ,(G_ "everything else.")))
>
> Some other outputs in the wild: "python", "utils", "xpi", "firefox",
> "chromium", "gui", "doc", "drill", "examples", "pyldns", "nm",
> "gtk2",
> "gtk3", "gtk4", "module", "src", "woff2", "headless", "installer",
> "jdk", "qt", "tester", "pulseaudio", "jack", "image", "opt-viewer",
> "examples", "metis", "cargo".
Oh, right, I just put in the most common ones. Of the ones you cite,
"doc", "examples", "gui", "src" "utils", and perhaps "cargo" make sense
if defined like this, the others appear rather specific. "python" in
particular sounds like it might have multiple meanings.

Cheers
L
L
Liliana Marie Prikler wrote on 18 Mar 21:25 +0100
1730db1e84a3b1529c148840e995794a2f57f216.camel@gmail.com
Am Freitag, dem 18.03.2022 um 21:16 +0100 schrieb Maxime Devos:
Toggle quote (5 lines)
> Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
> > +        (G_ "state secrets.")))))
>
> Wouldn't this require #:substitutable? #false?
> It's punny but rather inaccurate ...
You can substitute state secrets, but they will be marked to see who
leaked them. It's not like all of our outputs are 100% reproducible,
are they? :P
Toggle quote (2 lines)
> WDYT of adding a package property to allow packages to document
> unusual outputs?
That is literally the first thing I'm doing. It is unimaginatively
called 'output-descriptions and checked before either of the fallbacks.

Cheers
M
M
Maxime Devos wrote on 18 Mar 21:50 +0100
af17d6d557b34b5bae085fabe955952f7f8b7798.camel@telenet.be
Liliana Marie Prikler schreef op vr 18-03-2022 om 21:25 [+0100]:
Toggle quote (6 lines)
> > WDYT of adding a package property to allow packages to document
> > unusual outputs?
> That is literally the first thing I'm doing.  It is unimaginatively
> called 'output-descriptions and checked before either of the
> fallbacks.

Indeed, I overlooked that. That seems like something that needs to be
documented though (maybe in ‘package Reference’ or ‘Packages with
Multiple Outputs’, perhaps complemented by a linter that checks
that outputs without fallbacks are described in 'output-descriptions').

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjTwhRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7hEvAQD+Z9EnWefcM395vzrWgB1b2szD
K/lUPcfe5bhqlsPLrwD/Vww7iRLvO9CWS6X51vxyMf2Oi9nthOreYub4J4YZuww=
=ym9g
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 18 Mar 21:54 +0100
bcb31356f3821c2d5256fb0099a5395363ae7aa3.camel@telenet.be
Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
Toggle quote (2 lines)
> +    (let ((descs (assq-ref (package-properties package) 'output-descriptions)))

Should the descriptions be thunked, in case the package modules
are loaded before the locale is set, or if the locale changes during
execution? E.g., guix-data-service often changes locales, e.g. in
I don't know if old processes are reused or new processes are created,
but I'd assume the former.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjTxdxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ktKAP9pa/WWczsmmsHxaNZCD9OwDp8/
X367k/TthW07QLB1twD+JJ35YpTRarTu6A1qU3VAoeuETxoWlna7g0NW10c2BQM=
=nVgt
-----END PGP SIGNATURE-----


L
L
Liliana Marie Prikler wrote on 18 Mar 23:24 +0100
1cfdf03a949fa73b85c62dbe48732fe1bfc7b40b.camel@gmail.com
Am Freitag, dem 18.03.2022 um 21:54 +0100 schrieb Maxime Devos:
Toggle quote (12 lines)
> Liliana Marie Prikler schreef op vr 18-03-2022 om 20:16 [+0100]:
> > +    (let ((descs (assq-ref (package-properties package) 'output-
> > descriptions)))
>
> Should the descriptions be thunked, in case the package modules
> are loaded before the locale is set, or if the locale changes during
> execution?  E.g., guix-data-service often changes locales, e.g. in
> <
> https://git.savannah.gnu.org/cgit/guix/data-service.git/tree/guix-data-service/model/package-metadata.scm?id=8ab72e633ae700fe58bb3bf72aa155d62c2bc22e#n234
> >.
> I don't know if old processes are reused or new processes are
> created, but I'd assume the former.
Hmm, that's an interesting question. For what it's worth neither
synopsis nor description seem thunked and those are also localized, so
I don't think it'd be an issue.

Cheers
M
M
Maxime Devos wrote on 18 Mar 23:57 +0100
09888eaaa01111f34aae088ca84fdccfe1756103.camel@telenet.be
Liliana Marie Prikler schreef op vr 18-03-2022 om 23:24 [+0100]:
Toggle quote (4 lines)
> Hmm, that's an interesting question.  For what it's worth neither
> synopsis nor description seem thunked and those are also localized, so
> I don't think it'd be an issue.

Those work differently -- they don't use G_ or P_, instead the
localisation is delayed to 'package-field-string' and
'package->recutils'.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjUOQRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7msqAQCKNk6cQ5tWhTEdPHTQB3YSWpOq
9rBueUtixuxSymtgQAEA1FquES43FUI5ku+yYpIftfQaTZhbug3XWI1BKctPKQU=
=sKFq
-----END PGP SIGNATURE-----


L
L
Liliana Marie Prikler wrote on 19 Mar 00:27 +0100
0c9b516131eade349cee71d11da38762a224dc62.camel@gmail.com
Am Freitag, dem 18.03.2022 um 23:57 +0100 schrieb Maxime Devos:
Toggle quote (9 lines)
> Liliana Marie Prikler schreef op vr 18-03-2022 om 23:24 [+0100]:
> > Hmm, that's an interesting question.  For what it's worth neither
> > synopsis nor description seem thunked and those are also localized,
> > so
> > I don't think it'd be an issue.
>
> Those work differently -- they don't use G_ or P_, instead the
> localisation is delayed to 'package-field-string' and
> 'package->recutils'.
IOW we'd have to wrap (assoc-ref descs output) in an (and=> <> P_)?
M
M
Maxime Devos wrote on 19 Mar 09:56 +0100
42c9798380ec970dfdf7d3407cbd035b3821e758.camel@telenet.be
Liliana Marie Prikler schreef op za 19-03-2022 om 00:27 [+0100]:
Toggle quote (2 lines)
> IOW we'd have to wrap (assoc-ref descs output) in an (and=> <> P_)?

I don't think that's sufficient, somehow the strings need to end up in
the .po files. IIRC, there's some magic somewhere to add package
descriptions to the .po files even when they aren't wrapped in
(P_ "foo"), but I cannot locate it anywmore.

I was more thinking of:

(package
[...]
(properties
`((output-descriptions 
. ,(lambda () ("foo" . ,(G_ "Bar")) ...)))))

though bringing the magic used for package descriptions to
output descriptions would be tidier.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYjWaoRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7r2QAQDV/BjvxjJvHiGoZNQ+9T8nRsOW
AkjUX4MSUWolHypkcAEA4xzWqnPCx8upiqxinIVm4HW4pfBCcM0O+nGpEE/LaQ4=
=ia0u
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 19 Mar 11:48 +0100
Re: bug#54454: [PATCH] ui: Describe package outputs.
(name . Maxime Devos)(address . maximedevos@telenet.be)
87h77unrpg.fsf_-_@gnu.org
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (11 lines)
> I was more thinking of:
>
> (package
> [...]
> (properties
> `((output-descriptions 
> . ,(lambda () ("foo" . ,(G_ "Bar")) ...)))))
>
> though bringing the magic used for package descriptions to
> output descriptions would be tidier.

Rather:

(properties '((output-descriptions
("send-email" (synopsis "send email!")))))

That is, instead of calling ‘G_’, you just use one of the keywords
xgettext recognizes (see ‘po/packages/Makevars’). The actual call to
‘gettext’ would then be made in (guix ui).

I wonder if we’re going overboard though?

Ludo’.
L
L
Leo Famulari wrote on 19 Mar 17:24 +0100
Re: [bug#54454] [PATCH] ui: Describe package outputs.
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 54454@debbugs.gnu.org)
YjYDrIRxR4mv9tb7@jasmine.lan
On Fri, Mar 18, 2022 at 08:16:39PM +0100, Liliana Marie Prikler wrote:
Toggle quote (10 lines)
> * guix/ui.scm (package->recutils): Output outputs with their descriptions,
> one per line.
> ---
> Salut Guix,
>
> People have been complaining for a while, that outputs are not really
> discoverable [who?]. This patch attempts to fix that by displaying each
> on their own line with a (hopefully) helpful description next to it.
> It is expected, that these descriptions do not span multiple lines.

Excellent, thank you for stepping up to work on this!
L
L
Liliana Marie Prikler wrote on 26 Jun 14:37 +0200
[PATCH v2] ui: Describe package outputs.
(address . 54454@debbugs.gnu.org)
a4c86a2ce063a2b8e9d09625ce4c622c630d1ab8.camel@gmail.com
* guix/ui.scm (package->recutils): Output outputs with their descriptions,
one per line.
* po/packages/Makevars (XGETTEXT_OPTIONS): Add ‘output-synopsis’ as keyword.
---
guix/ui.scm | 27 ++++++++++++++++++++++++++-
po/packages/Makevars | 3 ++-
2 files changed, 28 insertions(+), 2 deletions(-)

Toggle diff (68 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index a7acd41440..dad2b853ac 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2018 Steve Sprang <scs@stevesprang.com>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
+;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1511,6 +1512,29 @@ (define (dependencies->recutils packages)
                                    (sort packages package<?))) " ")))
       (split-lines list (string-length "dependencies: "))))
 
+  (define (output->recutils package output)
+    (string-append
+     "+ " output ": "
+     (or
+      (any
+       (match-lambda
+         (('output-synopsis key synopsis)
+          (and (string=? key output) (P_ synopsis)))
+         (_ #f))
+       (package-properties package))
+      (assoc-ref `(("bin" . ,(G_ "executable programs and scripts"))
+                   ("debug" . ,(G_ "debug information"))
+                   ("lib" . ,(G_ "shared libraries"))
+                   ("static" . ,(G_ "static libraries"))
+                   ("out" . ,(G_ "everything else")))
+                 output)
+      (G_ "see Appendix H"))))
+
+  (define (package-outputs/out-last package)
+    ((compose append partition)
+     (negate (cut string=? "out" <>))
+     (package-outputs package)))
+
   (define (package<? p1 p2)
     (string<? (package-full-name p1) (package-full-name p2)))
 
@@ -1522,7 +1546,8 @@ (define highlighting*
   ;; Note: Don't i18n field names so that people can post-process it.
   (format port "name: ~a~%" (highlight (package-name p) port*))
   (format port "version: ~a~%" (highlight (package-version p) port*))
-  (format port "outputs: ~a~%" (string-join (package-outputs p)))
+  (format port "outputs:~%~{~a~%~}"
+          (map (cut output->recutils p <>) (package-outputs/out-last p)))
   (format port "systems: ~a~%"
           (split-lines (string-join (package-transitive-supported-systems p))
                        (string-length "systems: ")))
diff --git a/po/packages/Makevars b/po/packages/Makevars
index 4cdb98d8fe..65912786d8 100644
--- a/po/packages/Makevars
+++ b/po/packages/Makevars
@@ -10,7 +10,8 @@ top_builddir = ../..
 # synopses and descriptions.
 XGETTEXT_OPTIONS =				\
   --language=Scheme --from-code=UTF-8		\
-  --keyword=synopsis --keyword=description
+  --keyword=synopsis --keyword=description      \
+  --keyword=output-synopsis:2
 
 COPYRIGHT_HOLDER = the authors of Guix (msgids)
 
-- 
2.36.1
L
L
Liliana Marie Prikler wrote 23 hours ago
(address . 54454-done@debbugs.gnu.org)
19b47f93f45d15a366f3ec59ea8a6fa17b99d023.camel@gmail.com
Am Sonntag, dem 26.06.2022 um 14:37 +0200 schrieb Liliana Marie
Prikler:
Toggle quote (5 lines)
> * guix/ui.scm (package->recutils): Output outputs with their
> descriptions,
> one per line.
> * po/packages/Makevars (XGETTEXT_OPTIONS): Add ‘output-synopsis’ as
> keyword.
I pushed this now.

Cheers
Closed
?