* [bug#32998] [PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles
@ 2018-10-09 10:03 Ludovic Courtès
2018-10-09 10:16 ` [bug#32998] [PATCH 1/2] profiles: Generalize 'canonicalize-profile' Ludovic Courtès
2018-10-11 16:30 ` bug#32998: [PATCH 0/2] " Ludovic Courtès
0 siblings, 2 replies; 4+ messages in thread
From: Ludovic Courtès @ 2018-10-09 10:03 UTC (permalink / raw)
To: 32998
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug#32998] [PATCH 1/2] profiles: Generalize 'canonicalize-profile'.
2018-10-09 10:03 [bug#32998] [PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles Ludovic Courtès
@ 2018-10-09 10:16 ` Ludovic Courtès
2018-10-09 10:16 ` [bug#32998] [PATCH 2/2] pull: Turn ~/.config/guix/current into a symlink to /var/guix/profiles Ludovic Courtès
2018-10-11 16:30 ` bug#32998: [PATCH 0/2] " Ludovic Courtès
1 sibling, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2018-10-09 10:16 UTC (permalink / raw)
To: 32998
* 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [bug#32998] [PATCH 2/2] pull: Turn ~/.config/guix/current into a symlink to /var/guix/profiles.
2018-10-09 10:16 ` [bug#32998] [PATCH 1/2] profiles: Generalize 'canonicalize-profile' Ludovic Courtès
@ 2018-10-09 10:16 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2018-10-09 10:16 UTC (permalink / raw)
To: 32998
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))))
\f
+;;;
+;;; 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)))))))
+
+\f
;;;
;;; 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#32998: [PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles
2018-10-09 10:03 [bug#32998] [PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles Ludovic Courtès
2018-10-09 10:16 ` [bug#32998] [PATCH 1/2] profiles: Generalize 'canonicalize-profile' Ludovic Courtès
@ 2018-10-11 16:30 ` Ludovic Courtès
1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2018-10-11 16:30 UTC (permalink / raw)
To: 32998-done
Hello,
Ludovic Courtès <ludo@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’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-11 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-09 10:03 [bug#32998] [PATCH 0/2] Turn ~/.config/guix/current into a symlink to /var/guix/profiles Ludovic Courtès
2018-10-09 10:16 ` [bug#32998] [PATCH 1/2] profiles: Generalize 'canonicalize-profile' Ludovic Courtès
2018-10-09 10:16 ` [bug#32998] [PATCH 2/2] pull: Turn ~/.config/guix/current into a symlink to /var/guix/profiles Ludovic Courtès
2018-10-11 16:30 ` bug#32998: [PATCH 0/2] " Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.