Package: guix-patches;
Reported by: "(" <paren <at> disroot.org>
Date: Sun, 7 Aug 2022 11:15:02 UTC
Severity: normal
Tags: patch
To reply to this bug, email your comments to 57031 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 07 Aug 2022 11:15:02 GMT) Full text and rfc822 format available."(" <paren <at> disroot.org>
:guix-patches <at> gnu.org
.
(Sun, 07 Aug 2022 11:15:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: guix-patches <at> gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH] scripts: Show a hint the first time some commands are run as root. Date: Sun, 7 Aug 2022 12:14:21 +0100
* 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. --- guix/scripts/install.scm | 3 ++- guix/scripts/package.scm | 16 +++++++++++++--- guix/scripts/pull.scm | 7 +++++++ guix/scripts/remove.scm | 3 ++- guix/scripts/upgrade.scm | 3 ++- guix/ui.scm | 29 +++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm index 63e625f266..bf11fc7b11 100644 --- a/guix/scripts/install.scm +++ b/guix/scripts/install.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,4 +81,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 7d92598efa..8936c70e1f 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Josselin Poiret <dev <at> jpoiret.xyz> ;;; Copyright © 2022 Antero Mejr <antero <at> mailbox.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -1077,12 +1078,21 @@ (define opts (parse-command-line args %options (list %default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) -(define (guix-package* opts) +(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)) + (record-hint 'package-root-hint) + (display-hint (G_ "`guix package' is user-specific, not system-wide, +so running this command as root will affect only the `root' user."))) + (or (process-query opts) (parameterize ((%store (open-connection)) (%graft? (assoc-ref opts 'graft?))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index b0cc459d63..6e3d7db7c7 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com> ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me <at> tobias.gr> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -834,6 +835,12 @@ (define (no-arguments arg _) (current-channels (profile-channels profile)) (validate-pull (assoc-ref opts 'validate-pull)) (authenticate? (assoc-ref opts 'authenticate-channels?))) + (when (and (not (hint-given? 'pull-root-hint)) + (= (getuid) 0)) + (record-hint 'pull-root-hint) + (display-hint (G_ "`guix pull' is user-specific, not system-wide; +running it as root will only affect the `root' user."))) + (cond ((assoc-ref opts 'query) (process-query opts profile)) diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm index a46ad04d56..131649eace 100644 --- a/guix/scripts/remove.scm +++ b/guix/scripts/remove.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,4 +77,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm index beb59cbe6f..dd14600fe4 100644 --- a/guix/scripts/upgrade.scm +++ b/guix/scripts/upgrade.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,4 +88,4 @@ (define opts #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/ui.scm b/guix/ui.scm index a7acd41440..44607d80d2 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -18,6 +18,7 @@ ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -136,6 +137,11 @@ (define-module (guix ui) switch-to-generation* delete-generation* + hint-directory + hint-file + record-hint + hint-given? + %default-message-language current-message-language @@ -2032,6 +2038,29 @@ (define* (package-specification->name+version+output spec (package-name->name+version name))) (values name version sub-drv))) + +;;; +;;; One-time hints. +;;; + +(define (hint-directory) + "Return the directory name where previously given hints are recorded." + (string-append (cache-directory #:ensure? #f) "/hints")) + +(define (hint-file hint) + "Return the name of the file that marks HINT as already printed." + (string-append (hint-directory) "/" (symbol->string hint))) + +(define (record-hint hint) + "Mark HINT as already given." + (let ((file (hint-file hint))) + (mkdir-p (dirname file)) + (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) + +(define (hint-given? hint) + "Return true if HINT was already given." + (file-exists? (hint-file hint))) + ;;; ;;; Command-line option processing. -- 2.37.1
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 07 Aug 2022 11:20:01 GMT) Full text and rfc822 format available.Message #8 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH v2] scripts: Show a hint the first time some commands are run as root. Date: Sun, 7 Aug 2022 12:19:29 +0100
* 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. --- guix/scripts/install.scm | 3 ++- guix/scripts/package.scm | 16 +++++++++++++--- guix/scripts/pull.scm | 7 +++++++ guix/scripts/remove.scm | 3 ++- guix/scripts/shell.scm | 23 ----------------------- guix/scripts/upgrade.scm | 3 ++- guix/ui.scm | 29 +++++++++++++++++++++++++++++ 7 files changed, 55 insertions(+), 29 deletions(-) diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm index 63e625f266..bf11fc7b11 100644 --- a/guix/scripts/install.scm +++ b/guix/scripts/install.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,4 +81,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 7d92598efa..8936c70e1f 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Josselin Poiret <dev <at> jpoiret.xyz> ;;; Copyright © 2022 Antero Mejr <antero <at> mailbox.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -1077,12 +1078,21 @@ (define opts (parse-command-line args %options (list %default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) -(define (guix-package* opts) +(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)) + (record-hint 'package-root-hint) + (display-hint (G_ "`guix package' is user-specific, not system-wide, +so running this command as root will affect only the `root' user."))) + (or (process-query opts) (parameterize ((%store (open-connection)) (%graft? (assoc-ref opts 'graft?))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index b0cc459d63..6e3d7db7c7 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com> ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me <at> tobias.gr> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -834,6 +835,12 @@ (define (no-arguments arg _) (current-channels (profile-channels profile)) (validate-pull (assoc-ref opts 'validate-pull)) (authenticate? (assoc-ref opts 'authenticate-channels?))) + (when (and (not (hint-given? 'pull-root-hint)) + (= (getuid) 0)) + (record-hint 'pull-root-hint) + (display-hint (G_ "`guix pull' is user-specific, not system-wide; +running it as root will only affect the `root' user."))) + (cond ((assoc-ref opts 'query) (process-query opts profile)) diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm index a46ad04d56..131649eace 100644 --- a/guix/scripts/remove.scm +++ b/guix/scripts/remove.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,4 +77,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index c115a00320..3ac7d80eb0 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -489,29 +489,6 @@ (define (validated-spec spec) (exp (pretty-print exp port))))) - -;;; -;;; One-time hints. -;;; - -(define (hint-directory) - "Return the directory name where previously given hints are recorded." - (string-append (cache-directory #:ensure? #f) "/hints")) - -(define (hint-file hint) - "Return the name of the file that marks HINT as already printed." - (string-append (hint-directory) "/" (symbol->string hint))) - -(define (record-hint hint) - "Mark HINT as already given." - (let ((file (hint-file hint))) - (mkdir-p (dirname file)) - (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) - -(define (hint-given? hint) - "Return true if HINT was already given." - (file-exists? (hint-file hint))) - (define-command (guix-shell . args) (category development) diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm index beb59cbe6f..dd14600fe4 100644 --- a/guix/scripts/upgrade.scm +++ b/guix/scripts/upgrade.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,4 +88,4 @@ (define opts #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/ui.scm b/guix/ui.scm index a7acd41440..44607d80d2 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -18,6 +18,7 @@ ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com> ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -136,6 +137,11 @@ (define-module (guix ui) switch-to-generation* delete-generation* + hint-directory + hint-file + record-hint + hint-given? + %default-message-language current-message-language @@ -2032,6 +2038,29 @@ (define* (package-specification->name+version+output spec (package-name->name+version name))) (values name version sub-drv))) + +;;; +;;; One-time hints. +;;; + +(define (hint-directory) + "Return the directory name where previously given hints are recorded." + (string-append (cache-directory #:ensure? #f) "/hints")) + +(define (hint-file hint) + "Return the name of the file that marks HINT as already printed." + (string-append (hint-directory) "/" (symbol->string hint))) + +(define (record-hint hint) + "Mark HINT as already given." + (let ((file (hint-file hint))) + (mkdir-p (dirname file)) + (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) + +(define (hint-given? hint) + "Return true if HINT was already given." + (file-exists? (hint-file hint))) + ;;; ;;; Command-line option processing. -- 2.37.1
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 07 Aug 2022 11:23:02 GMT) Full text and rfc822 format available.Message #11 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: "(" <paren <at> disroot.org>, <57031 <at> debbugs.gnu.org> Subject: Re: [PATCH v2] scripts: Show a hint the first time some commands are run as root. Date: Sun, 07 Aug 2022 12:22:41 +0100
This patch tries to solve the same problem as #57016, except instead of bailing out on `sudo guix pull`, `sudo guix package`, or similar, it displays a hint the first time they are run advising users that Guix's package management is per-user. -- (
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Mon, 05 Sep 2022 21:12:02 GMT) Full text and rfc822 format available.Message #14 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: "(" <paren <at> disroot.org> Cc: 57031 <at> debbugs.gnu.org Subject: Re: 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
Hello, "(" <paren <at> 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’.
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 11 Sep 2022 13:06:01 GMT) Full text and rfc822 format available.Message #17 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: Ludovic Courtès <ludo <at> gnu.org> Cc: 57031 <at> debbugs.gnu.org Subject: Re: bug#57031: [PATCH] scripts: Show a hint the first time some commands are run as root. Date: Sun, 11 Sep 2022 14:05:28 +0100
Hey Ludo, On Mon Sep 5, 2022 at 10:11 PM BST, Ludovic Courtès wrote: > One nitpick: Could you make moving the hint code from shell.scm to > ui.scm a separate commit? Sure! > > + (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.) Oh, I didn't realize you could do that. > > +(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? No, it's not always true; we don't use `#:root-hint #t' in `guix search' and `guix show', so that `sudo guix show foobar' doesn't trigger the root hint. > BTW, when running ‘sudo guix install’, the hint is going to > ~root/.cache/guix, right? Probably -.o.- -- (
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 11 Sep 2022 20:00:02 GMT) Full text and rfc822 format available.Message #20 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH v2 1/2] ui: Make one-time hint API public. Date: Sun, 11 Sep 2022 20:59:40 +0100
* guix/scripts/shell.scm (hint-directory, hint-file, record-hint, hint-given?): Move these... * guix/ui.scm (hint-directory, hint-file, record-hint, hint-given?): ...here. --- guix/scripts/shell.scm | 23 ----------------------- guix/ui.scm | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index c115a00320..3ac7d80eb0 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -489,29 +489,6 @@ (define (validated-spec spec) (exp (pretty-print exp port))))) - -;;; -;;; One-time hints. -;;; - -(define (hint-directory) - "Return the directory name where previously given hints are recorded." - (string-append (cache-directory #:ensure? #f) "/hints")) - -(define (hint-file hint) - "Return the name of the file that marks HINT as already printed." - (string-append (hint-directory) "/" (symbol->string hint))) - -(define (record-hint hint) - "Mark HINT as already given." - (let ((file (hint-file hint))) - (mkdir-p (dirname file)) - (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) - -(define (hint-given? hint) - "Return true if HINT was already given." - (file-exists? (hint-file hint))) - (define-command (guix-shell . args) (category development) diff --git a/guix/ui.scm b/guix/ui.scm index dad2b853ac..3512c761d2 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -19,6 +19,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info> ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -137,6 +138,11 @@ (define-module (guix ui) switch-to-generation* delete-generation* + hint-directory + hint-file + record-hint + hint-given? + %default-message-language current-message-language @@ -2057,6 +2063,29 @@ (define* (package-specification->name+version+output spec (package-name->name+version name))) (values name version sub-drv))) + +;;; +;;; One-time hints. +;;; + +(define (hint-directory) + "Return the directory name where previously given hints are recorded." + (string-append (cache-directory #:ensure? #f) "/hints")) + +(define (hint-file hint) + "Return the name of the file that marks HINT as already printed." + (string-append (hint-directory) "/" (symbol->string hint))) + +(define (record-hint hint) + "Mark HINT as already given." + (let ((file (hint-file hint))) + (mkdir-p (dirname file)) + (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) + +(define (hint-given? hint) + "Return true if HINT was already given." + (file-exists? (hint-file hint))) + ;;; ;;; Command-line option processing. -- 2.37.3
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Sun, 11 Sep 2022 20:00:02 GMT) Full text and rfc822 format available.Message #23 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Date: Sun, 11 Sep 2022 20:59:41 +0100
* guix/scripts/pull.scm (guix-pull): Warn the first time it's being run as root. * guix/scripts/package.scm (guix-package*): Likewise if the new `root-hint?' argument is `#t'. (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'. * guix/scripts/install.scm (guix-install): Likewise. * guix/scripts/remove.scm (guix-remove): Likewise. * guix/scripts/remove.scm (guix-upgrade): Likewise. 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 warning the first time they are run as root. --- guix/scripts/install.scm | 3 ++- guix/scripts/package.scm | 15 ++++++++++++--- guix/scripts/pull.scm | 6 ++++++ guix/scripts/remove.scm | 3 ++- guix/scripts/upgrade.scm | 3 ++- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm index 63e625f266..bf11fc7b11 100644 --- a/guix/scripts/install.scm +++ b/guix/scripts/install.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,4 +81,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 7ba2661bbb..7379e69388 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Josselin Poiret <dev <at> jpoiret.xyz> ;;; Copyright © 2022 Antero Mejr <antero <at> mailbox.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -1079,12 +1080,20 @@ (define opts (parse-command-line args %options (list %default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) -(define (guix-package* opts) +(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)) + (zero? (getuid))) + (record-hint 'package-root-hint) + (warning (G_ "this command is user-specific, so running it as root \ +will affect only the 'root' user~%"))) (or (process-query opts) (parameterize ((%store (open-connection)) (%graft? (assoc-ref opts 'graft?))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 19224cf70b..188b632450 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com> ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me <at> tobias.gr> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -827,6 +828,11 @@ (define (no-arguments arg _) (leave (G_ "~A: extraneous argument~%") arg)) (with-error-handling + (when (and (not (hint-given? 'pull-root-hint)) + (zero? (getuid))) + (record-hint 'pull-root-hint) + (warning (G_ "this command is user-specific, so running it as root \ +will affect only the 'root' user~%"))) (with-git-error-handling (let* ((opts (parse-command-line args %options (list %default-options) diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm index a46ad04d56..131649eace 100644 --- a/guix/scripts/remove.scm +++ b/guix/scripts/remove.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,4 +77,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm index beb59cbe6f..dd14600fe4 100644 --- a/guix/scripts/upgrade.scm +++ b/guix/scripts/upgrade.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,4 +88,4 @@ (define opts #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) -- 2.37.3
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Wed, 26 Oct 2022 22:54:02 GMT) Full text and rfc822 format available.Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):
From: zimoun <zimon.toutoune <at> gmail.com> To: "( via Guix-patches via" <guix-patches <at> gnu.org>, 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: Re: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Date: Wed, 26 Oct 2022 20:14:49 +0200
Hi, On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via <guix-patches <at> gnu.org> wrote: > * guix/scripts/pull.scm (guix-pull): Warn the first time it's being > run as root. > * guix/scripts/package.scm (guix-package*): Likewise if the new > `root-hint?' argument is `#t'. > (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'. > * guix/scripts/install.scm (guix-install): Likewise. > * guix/scripts/remove.scm (guix-remove): Likewise. > * guix/scripts/remove.scm (guix-upgrade): Likewise. > > 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 warning the first time they are run as root. This patch LGTM aside… > - (guix-package* opts)) > + (guix-package* opts #:root-hint? #t)) [...] > - (guix-package* opts)) > + (guix-package* opts #:root-hint? #t)) [...] > -(define (guix-package* opts) > +(define* (guix-package* opts #:key (root-hint? #f)) Why this ’root-hint?’ argument? Is it useful or can we drop it? > + (when (and root-hint? > + (not (hint-given? 'package-root-hint)) > + (zero? (getuid))) > + (record-hint 'package-root-hint) > + (warning (G_ "this command is user-specific, so running it as root \ > +will affect only the 'root' user~%"))) [...] > + (when (and (not (hint-given? 'pull-root-hint)) > + (zero? (getuid))) > + (record-hint 'pull-root-hint) > + (warning (G_ "this command is user-specific, so running it as root \ > +will affect only the 'root' user~%"))) It looks pretty similar. Is it possible to avoid the duplication? Cheers, simon
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Wed, 26 Oct 2022 22:54:03 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Thu, 27 Oct 2022 05:53:02 GMT) Full text and rfc822 format available.Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: "zimoun" <zimon.toutoune <at> gmail.com>, "( via Guix-patches via" <guix-patches <at> gnu.org>, <57031 <at> debbugs.gnu.org> Subject: Re: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Date: Thu, 27 Oct 2022 06:52:36 +0100
Heya, On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote: > > - (guix-package* opts)) > > + (guix-package* opts #:root-hint? #t)) > > [...] > > > - (guix-package* opts)) > > + (guix-package* opts #:root-hint? #t)) > > [...] > > > -(define (guix-package* opts) > > +(define* (guix-package* opts #:key (root-hint? #f)) > > Why this ’root-hint?’ argument? Is it useful or can we drop it? This allows us to disable root hints for ``guix package'' variants, so eg ``sudo guix show'' will not trigger the root hint. > > + (when (and root-hint? > > + (not (hint-given? 'package-root-hint)) > > + (zero? (getuid))) > > + (record-hint 'package-root-hint) > > + (warning (G_ "this command is user-specific, so running it as root \ > > +will affect only the 'root' user~%"))) > > [...] > > > + (when (and (not (hint-given? 'pull-root-hint)) > > + (zero? (getuid))) > > + (record-hint 'pull-root-hint) > > + (warning (G_ "this command is user-specific, so running it as root \ > > +will affect only the 'root' user~%"))) > > It looks pretty similar. Is it possible to avoid the duplication? ...I guess? Maybe we could do something like this?: ;;;; guix/scripts.scm (define (warn-if-root hint-name) (when (and (not (hint-given hint-name)) (zero? (getuid))) (record-hint hint-name) (warning (G_ "this command is user-specific, so running it as root \ > > +will affect only the 'root' user~%")))) ;;;; guix/scripts/package.scm (when root-hint? (warn-if-root 'package-root-hint)) ;;;; guix/scripts/pull.scm (warn-if-root 'pull-root-hint) -- (
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Thu, 27 Oct 2022 05:53:02 GMT) Full text and rfc822 format available.guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Thu, 27 Oct 2022 19:43:01 GMT) Full text and rfc822 format available.Message #38 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH v3 1/2] ui: Make one-time hint API public. Date: Thu, 27 Oct 2022 20:42:42 +0100
* guix/scripts/shell.scm (hint-directory, hint-file, record-hint, hint-given?): Move these... * guix/ui.scm (hint-directory, hint-file, record-hint, hint-given?): ...here. --- guix/scripts/shell.scm | 23 ----------------------- guix/ui.scm | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index a2836629ad..c66ff4e5c4 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -505,29 +505,6 @@ (define (validated-spec spec) (exp (pretty-print exp port))))) - -;;; -;;; One-time hints. -;;; - -(define (hint-directory) - "Return the directory name where previously given hints are recorded." - (string-append (cache-directory #:ensure? #f) "/hints")) - -(define (hint-file hint) - "Return the name of the file that marks HINT as already printed." - (string-append (hint-directory) "/" (symbol->string hint))) - -(define (record-hint hint) - "Mark HINT as already given." - (let ((file (hint-file hint))) - (mkdir-p (dirname file)) - (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) - -(define (hint-given? hint) - "Return true if HINT was already given." - (file-exists? (hint-file hint))) - (define-command (guix-shell . args) (category development) diff --git a/guix/ui.scm b/guix/ui.scm index dad2b853ac..3512c761d2 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -19,6 +19,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info> ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -137,6 +138,11 @@ (define-module (guix ui) switch-to-generation* delete-generation* + hint-directory + hint-file + record-hint + hint-given? + %default-message-language current-message-language @@ -2057,6 +2063,29 @@ (define* (package-specification->name+version+output spec (package-name->name+version name))) (values name version sub-drv))) + +;;; +;;; One-time hints. +;;; + +(define (hint-directory) + "Return the directory name where previously given hints are recorded." + (string-append (cache-directory #:ensure? #f) "/hints")) + +(define (hint-file hint) + "Return the name of the file that marks HINT as already printed." + (string-append (hint-directory) "/" (symbol->string hint))) + +(define (record-hint hint) + "Mark HINT as already given." + (let ((file (hint-file hint))) + (mkdir-p (dirname file)) + (close-fdes (open-fdes file (logior O_CREAT O_WRONLY))))) + +(define (hint-given? hint) + "Return true if HINT was already given." + (file-exists? (hint-file hint))) + ;;; ;;; Command-line option processing. base-commit: f928abac369f699f425ddee925d0d0c2dc0a635d -- 2.38.0
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Thu, 27 Oct 2022 19:43:02 GMT) Full text and rfc822 format available.Message #41 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: 57031 <at> debbugs.gnu.org Cc: "\(" <paren <at> disroot.org> Subject: [PATCH v3 2/2] scripts: Warn the first time pull or package is run as root. Date: Thu, 27 Oct 2022 20:42:43 +0100
* guix/ui.scm (root-warning): New variable. * guix/scripts/pull.scm (guix-pull): Warn the first time it's being run as root. * guix/scripts/package.scm (guix-package*): Likewise if the new `root-hint?' argument is `#t'. (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'. * guix/scripts/install.scm (guix-install): Likewise. * guix/scripts/remove.scm (guix-remove): Likewise. * guix/scripts/remove.scm (guix-upgrade): Likewise. 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 warning the first time they are run as root. --- guix/scripts/install.scm | 3 ++- guix/scripts/package.scm | 11 ++++++++--- guix/scripts/pull.scm | 2 ++ guix/scripts/remove.scm | 3 ++- guix/scripts/upgrade.scm | 3 ++- guix/ui.scm | 8 ++++++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm index 63e625f266..bf11fc7b11 100644 --- a/guix/scripts/install.scm +++ b/guix/scripts/install.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,4 +81,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index b9090307ac..10cf32475b 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com> ;;; Copyright © 2022 Josselin Poiret <dev <at> jpoiret.xyz> ;;; Copyright © 2022 Antero Mejr <antero <at> mailbox.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -1078,12 +1079,16 @@ (define opts (parse-command-line args %options (list %default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) -(define (guix-package* opts) +(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 root-hint? + (root-warning 'package-root-hint)) (or (process-query opts) (parameterize ((%store (open-connection)) (%graft? (assoc-ref opts 'graft?))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 7b6c58dbc3..98aaf0b377 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com> ;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me <at> tobias.gr> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -826,6 +827,7 @@ (define (no-arguments arg _) (leave (G_ "~A: extraneous argument~%") arg)) (with-error-handling + (root-warning 'pull-root-hint) (with-git-error-handling (let* ((opts (parse-command-line args %options (list %default-options) diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm index a46ad04d56..131649eace 100644 --- a/guix/scripts/remove.scm +++ b/guix/scripts/remove.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,4 +77,4 @@ (define opts (list %package-default-options #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm index beb59cbe6f..dd14600fe4 100644 --- a/guix/scripts/upgrade.scm +++ b/guix/scripts/upgrade.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo <at> gnu.org> ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net> ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com> +;;; Copyright © 2022 ( <paren <at> disroot.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,4 +88,4 @@ (define opts #f) #:argument-handler handle-argument)) - (guix-package* opts)) + (guix-package* opts #:root-hint? #t)) diff --git a/guix/ui.scm b/guix/ui.scm index 3512c761d2..0f1a603025 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -142,6 +142,7 @@ (define-module (guix ui) hint-file record-hint hint-given? + root-warning %default-message-language current-message-language @@ -2086,6 +2087,13 @@ (define (hint-given? hint) "Return true if HINT was already given." (file-exists? (hint-file hint))) +(define (root-warning hint-name) + (when (and (not (hint-given? hint-name)) + (zero? (getuid))) + (record-hint hint-name) + (warning (G_ "this command is user-specific, so running it as root \ +will affect only the 'root' user~%")))) + ;;; ;;; Command-line option processing. -- 2.38.0
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Fri, 28 Oct 2022 08:48:03 GMT) Full text and rfc822 format available.Message #44 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: zimoun <zimon.toutoune <at> gmail.com> To: "(" <paren <at> disroot.org>, 57031 <at> debbugs.gnu.org Subject: Re: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Date: Thu, 27 Oct 2022 10:23:19 +0200
Hi, On Thu, 27 Oct 2022 at 06:52, "\( via Guix-patches" via <guix-patches <at> gnu.org> wrote: > On Wed Oct 26, 2022 at 7:14 PM BST, zimoun wrote: >> > - (guix-package* opts)) >> > + (guix-package* opts #:root-hint? #t)) >> >> [...] >> >> > - (guix-package* opts)) >> > + (guix-package* opts #:root-hint? #t)) >> >> [...] >> >> > -(define (guix-package* opts) >> > +(define* (guix-package* opts #:key (root-hint? #f)) >> >> Why this ’root-hint?’ argument? Is it useful or can we drop it? > > This allows us to disable root hints for ``guix package'' variants, so eg > ``sudo guix show'' will not trigger the root hint. Ah, I see. But then, guix package --show=hello would print the hint, no? > ;;;; guix/scripts.scm > > (define (warn-if-root hint-name) > (when (and (not (hint-given hint-name)) > (zero? (getuid))) > (record-hint hint-name) > (warning (G_ "this command is user-specific, so running it as root \ > > > +will affect only the 'root' user~%")))) > > ;;;; guix/scripts/package.scm > > (when root-hint? > (warn-if-root 'package-root-hint)) > > ;;;; guix/scripts/pull.scm > > (warn-if-root 'pull-root-hint) Something like that SGTM. Cheers, simon
guix-patches <at> gnu.org
:bug#57031
; Package guix-patches
.
(Fri, 28 Oct 2022 14:46:02 GMT) Full text and rfc822 format available.Message #47 received at 57031 <at> debbugs.gnu.org (full text, mbox):
From: "(" <paren <at> disroot.org> To: "zimoun" <zimon.toutoune <at> gmail.com>, <57031 <at> debbugs.gnu.org> Subject: Re: [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. Date: Fri, 28 Oct 2022 15:33:35 +0100
On Thu Oct 27, 2022 at 9:23 AM BST, zimoun wrote: > Ah, I see. But then, > > guix package --show=hello > > would print the hint, no? Sadly, yes. I'm not sure how to remedy this, and it doesn't seem too consequential; I've never seen someone using ``--show'' or ``--search'' in practice. -- (
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.