diff mbox series

[bug#54454] ui: Describe package outputs.

Message ID cf9713d087089126b1f8b9102cb8f37a879fa6fd.camel@gmail.com
State Accepted
Headers show
Series [bug#54454] ui: Describe package outputs. | expand

Checks

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

Commit Message

Liliana Marie Prikler March 18, 2022, 7:16 p.m. UTC
* 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(-)

Comments

M March 18, 2022, 8:12 p.m. UTC | #1
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".

Greetings,
Maxime.
M March 18, 2022, 8:16 p.m. UTC | #2
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 ...
WDYT of adding a package property to allow packages to document unusual
outputs?

Greetings,
Maxime.
Liliana Marie Prikler March 18, 2022, 8:23 p.m. UTC | #3
Am Freitag, dem 18.03.2022 um 21:12 +0100 schrieb Maxime Devos:
> 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
Liliana Marie Prikler March 18, 2022, 8:25 p.m. UTC | #4
Am Freitag, dem 18.03.2022 um 21:16 +0100 schrieb Maxime Devos:
> 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
> 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 March 18, 2022, 8:50 p.m. UTC | #5
Liliana Marie Prikler schreef op vr 18-03-2022 om 21:25 [+0100]:
> > 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.
M March 18, 2022, 8:54 p.m. UTC | #6
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.

Greetings,
Maxime.
Liliana Marie Prikler March 18, 2022, 10:24 p.m. UTC | #7
Am Freitag, dem 18.03.2022 um 21:54 +0100 schrieb Maxime Devos:
> 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 March 18, 2022, 10:57 p.m. UTC | #8
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'.
Liliana Marie Prikler March 18, 2022, 11:27 p.m. UTC | #9
Am Freitag, dem 18.03.2022 um 23:57 +0100 schrieb Maxime Devos:
> 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 March 19, 2022, 8:56 a.m. UTC | #10
Liliana Marie Prikler schreef op za 19-03-2022 om 00:27 [+0100]:
> 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.
Ludovic Courtès March 19, 2022, 10:48 a.m. UTC | #11
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> 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’.
Leo Famulari March 19, 2022, 4:24 p.m. UTC | #12
On Fri, Mar 18, 2022 at 08:16:39PM +0100, Liliana Marie Prikler wrote:
> * 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!
diff mbox series

Patch

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: ")))