GNU bug report logs -
#32998
[PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Tue, 9 Oct 2018 10:04:01 UTC
Severity: normal
Tags: patch
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32998 in the body.
You can then email your comments to 32998 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#32998
; Package
guix-patches
.
(Tue, 09 Oct 2018 10:04:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Tue, 09 Oct 2018 10:04:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi there!
The following patches turn ~/.config/guix/current into a symlink to
/var/guix/profiles/per-user/$USER/current-guix, in a way that is
consistent with what ‘guix package’ does.
Note that ‘guix pull’ will automatically move your generations from
~/.config/guix to /var/guix/profiles/per-user/$USER the first time
you run it.
This will allow us to fix <https://bugs.gnu.org/32183> nicely.
Objections?
Ludo’.
Ludovic Courtès (2):
profiles: Generalize 'canonicalize-profile'.
pull: Turn ~/.config/guix/current into a symlink to
/var/guix/profiles.
doc/guix.texi | 2 +-
guix/profiles.scm | 23 ++++++++-------
guix/scripts/pull.scm | 65 +++++++++++++++++++++++++++++++++++++++++--
3 files changed, 74 insertions(+), 16 deletions(-)
--
2.19.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32998
; Package
guix-patches
.
(Tue, 09 Oct 2018 10:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 32998 <at> debbugs.gnu.org (full text, mbox):
* guix/profiles.scm (canonicalize-profile): Rewrite to work with any
profile that lives under %PROFILE-DIRECTORY.
---
guix/profiles.scm | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index de3a04464..6b911b3fe 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1611,19 +1611,18 @@ because the NUMBER is zero.)"
(string-append %profile-directory "/guix-profile"))
(define (canonicalize-profile profile)
- "If PROFILE is %USER-PROFILE-DIRECTORY, return %CURRENT-PROFILE. Otherwise
-return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile' as if
-'-p' was omitted." ; see <http://bugs.gnu.org/17939>
-
- ;; Trim trailing slashes so that the basename comparison below works as
- ;; intended.
+ "If PROFILE points to a profile in %PROFILE-DIRECTORY, return that.
+Otherwise return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile'
+as if '-p' was omitted." ; see <http://bugs.gnu.org/17939>
+ ;; Trim trailing slashes so 'readlink' can do its job.
(let ((profile (string-trim-right profile #\/)))
- (if (and %user-profile-directory
- (string=? (canonicalize-path (dirname profile))
- (dirname %user-profile-directory))
- (string=? (basename profile) (basename %user-profile-directory)))
- %current-profile
- profile)))
+ (catch 'system-error
+ (lambda ()
+ (let ((target (readlink profile)))
+ (if (string=? (dirname target) %profile-directory)
+ target
+ profile)))
+ (const profile))))
(define (user-friendly-profile profile)
"Return either ~/.guix-profile if that's what PROFILE refers to, directly or
--
2.19.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#32998
; Package
guix-patches
.
(Tue, 09 Oct 2018 10:18:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 32998 <at> debbugs.gnu.org (full text, mbox):
This is more consistent with what 'guix package' does, more pleasant for
users (we no longer clobber ~/.config/guix), and more
cluster-friendly (since /var/guix/profiles is usually an NFS share
already.)
* guix/scripts/pull.scm (%current-profile, %user-profile-directory): New
variables.
(migrate-generations, ensure-default-profile): New procedures.
(guix-pull): Use %CURRENT-PROFILE by default. Call
'ensure-default-profile'.
* doc/guix.texi (Invoking guix pull): Adjust 'guix package -p
~/.config/guix/current' example.
---
doc/guix.texi | 2 +-
guix/scripts/pull.scm | 65 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 3c116fc0b..c6e474955 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2831,7 +2831,7 @@ generation---i.e., the previous Guix---and so on:
$ guix package -p ~/.config/guix/current --roll-back
switched from generation 3 to 2
$ guix package -p ~/.config/guix/current --delete-generations=1
-deleting /home/charlie/.config/guix/current-1-link
+deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
@end example
The @command{guix pull} command is usually invoked with no arguments,
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 0d65857be..042b493ae 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -226,6 +226,66 @@ Download and deploy the latest version of Guix.\n"))
(report-git-error err))))
+;;;
+;;; Profile.
+;;;
+
+(define %current-profile
+ ;; The "real" profile under /var/guix.
+ (string-append %profile-directory "/current-guix"))
+
+(define %user-profile-directory
+ ;; The user-friendly name of %CURRENT-PROFILE.
+ (string-append (config-directory #:ensure? #f) "/current"))
+
+(define (migrate-generations profile directory)
+ "Migration the generations of PROFILE to DIRECTORY."
+ (format (current-error-port)
+ (G_ "Migrating profile generations to '~a'...~%")
+ %profile-directory)
+ (for-each (lambda (generation)
+ (let ((source (generation-file-name profile generation))
+ (target (string-append directory "/current-guix-"
+ (number->string generation)
+ "-link")))
+ (rename-file source target)))
+ (profile-generations profile)))
+
+(define (ensure-default-profile)
+ (catch 'system-error
+ (lambda ()
+ ;; Note: The /per-user directory, parent of %PROFILE-DIRECTORY, is
+ ;; created by the daemon. Assume it already exists.
+ (mkdir %profile-directory))
+ (lambda args
+ (unless (= EEXIST (system-error-errno args))
+ (format (current-error-port)
+ (G_ "error: while creating directory `~a': ~a~%")
+ %profile-directory
+ (strerror (system-error-errno args)))
+ (format (current-error-port)
+ (G_ "Please create the `~a' directory, with you as the owner.~%")
+ %profile-directory))))
+
+ ;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move
+ ;; them to %PROFILE-DIRECTORY.
+ (unless (string=? %profile-directory
+ (dirname (canonicalize-profile %user-profile-directory)))
+ (migrate-generations %user-profile-directory %profile-directory))
+
+ ;; Recreate ~/.config/guix/current. Recreating it is a way to have an
+ ;; up-to-date mtime on the link, which we can then use to determine the time
+ ;; of the last update (XXX: we could do better...).
+ (let ((link %user-profile-directory))
+ (false-if-exception (delete-file link))
+ (catch 'system-error
+ (lambda ()
+ (symlink %current-profile link))
+ (lambda args
+ (leave (G_ "while creating symlink '~a': ~a~%")
+ link (strerror (system-error-errno args)))))))
+
+
;;;
;;; Queries.
;;;
@@ -438,9 +498,8 @@ Use '~/.config/guix/channels.scm' instead."))
(list %default-options)))
(cache (string-append (cache-directory) "/pull"))
(channels (channel-list opts))
- (profile (or (assoc-ref opts 'profile)
- (string-append (config-directory) "/current"))))
-
+ (profile (or (assoc-ref opts 'profile) %current-profile)))
+ (ensure-default-profile)
(cond ((assoc-ref opts 'query)
(process-query opts profile))
((assoc-ref opts 'dry-run?)
--
2.19.0
Reply sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
You have taken responsibility.
(Thu, 11 Oct 2018 16:31:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
bug acknowledged by developer.
(Thu, 11 Oct 2018 16:31:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 32998-done <at> debbugs.gnu.org (full text, mbox):
Hello,
Ludovic Courtès <ludo <at> gnu.org> skribis:
> The following patches turn ~/.config/guix/current into a symlink to
> /var/guix/profiles/per-user/$USER/current-guix, in a way that is
> consistent with what ‘guix package’ does.
>
> Note that ‘guix pull’ will automatically move your generations from
> ~/.config/guix to /var/guix/profiles/per-user/$USER the first time
> you run it.
Applied with minor refactoring (the ‘ensure-profile-directory’ thing.)
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 09 Nov 2018 12:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.