guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#57031] [PATCH] scripts: Show a hint the first time some commands ar


From: Ludovic Courtès
Subject: [bug#57031] [PATCH] scripts: Show a hint the first time some commands are run as root.
Date: Mon, 05 Sep 2022 23:11:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Hello,

"(" <paren@disroot.org> skribis:

> * guix/scripts/shell.scm (hint-given?, hint-directory, hint-file,
>   record-hint): Move these...
> * guix/ui.scm: ...here. Export them.
> * guix/scripts/package.scm (guix-package*): Add `#:root-hint?` keyword
>   argument. Display a hint if Guix is being run as root and `root-hint?`
>   is #t.
> * guix/scripts/install.scm (guix-install): Use `#:root-hint? #t` here...
> * guix/scripts/remove.scm (guix-remove): ...here...
> * guix/scripts/upgrade.scm (guix-upgrade): ...and here.
> * guix/scripts/pull.scm (guix-pull): (guix-pull): Display a hint if
>   Guix is being run as root.
>
> A pretty common beginner mistake, it seems, is assuming that since
> every other package manager you've used requires root for installing,
> removing, and upgrading packages, Guix must too.
>
> This commit tries to make it harder to make such an assumption, by
> making commands such as `pull`, `package`, and `upgrade` display
> a hint the first time they are run as root.

I like this change!

One nitpick: Could you make moving the hint code from shell.scm to
ui.scm a separate commit?


[...]

> +         (display-hint (G_ "`guix pull' is user-specific, not system-wide;
> +running it as root will only affect the `root' user.")))

Please use Texinfo markup in hints: @command{guix pull}, etc.  (Likewise
for the second hint.)

> +(define* (guix-package* opts #:key (root-hint? #f))
>    "Run the 'guix package' command on OPTS, an alist resulting for 
> command-line
> -option processing with 'parse-command-line'."
> +option processing with 'parse-command-line'.  If ROOT-HINT? is #T, a hint is
> +shown on the first usage of this procedure that informs users about Guix's
> +support for per-user package management."
>    (with-error-handling
> +    (when (and root-hint?
> +               (not (hint-given? 'package-root-hint))
> +               (= (getuid) 0))

Unless I’m mistaken, ‘root-hint?’ is always true; should we just remove
it?

BTW, when running ‘sudo guix install’, the hint is going to
~root/.cache/guix, right?

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]