[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/10: profiles: Add '%current-profile', 'user-friendly-profile', & co.
From: |
Ludovic Courtès |
Subject: |
07/10: profiles: Add '%current-profile', 'user-friendly-profile', & co. |
Date: |
Sat, 9 Jun 2018 06:02:39 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit efcb4441f1c2dd6729938ca68f2fdfd6243e24e4
Author: Ludovic Courtès <address@hidden>
Date: Sun May 13 16:08:24 2018 +0200
profiles: Add '%current-profile', 'user-friendly-profile', & co.
* guix/scripts/package.scm (%user-profile-directory)
(%profile-directory, %current-profile, canonicalize-profile)
(user-friendly-profile): Move to...
* guix/profiles.scm: ... here.
---
guix/profiles.scm | 49 +++++++++++++++++++++++++++++++++++++++++++++++-
guix/scripts/package.scm | 40 ---------------------------------------
2 files changed, 48 insertions(+), 41 deletions(-)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 9bddf88..95a8f30 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -25,6 +25,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix profiles)
+ #:use-module ((guix config) #:select (%state-directory))
#:use-module ((guix utils) #:hide (package-name->name+version))
#:use-module ((guix build utils)
#:select (package-name->name+version))
@@ -118,7 +119,13 @@
generation-file-name
switch-to-generation
roll-back
- delete-generation))
+ delete-generation
+
+ %user-profile-directory
+ %profile-directory
+ %current-profile
+ canonicalize-profile
+ user-friendly-profile))
;;; Commentary:
;;;
@@ -1515,4 +1522,44 @@ because the NUMBER is zero.)"
(else
(delete-and-return)))))
+(define %user-profile-directory
+ (and=> (getenv "HOME")
+ (cut string-append <> "/.guix-profile")))
+
+(define %profile-directory
+ (string-append %state-directory "/profiles/"
+ (or (and=> (or (getenv "USER")
+ (getenv "LOGNAME"))
+ (cut string-append "per-user/" <>))
+ "default")))
+
+(define %current-profile
+ ;; Call it `guix-profile', not `profile', to allow Guix profiles to
+ ;; coexist with Nix profiles.
+ (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.
+ (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)))
+
+(define (user-friendly-profile profile)
+ "Return either ~/.guix-profile if that's what PROFILE refers to, directly or
+indirectly, or PROFILE."
+ (if (and %user-profile-directory
+ (false-if-exception
+ (string=? (readlink %user-profile-directory) profile)))
+ %user-profile-directory
+ profile))
+
;;; profiles.scm ends here
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 4f519e6..29829f5 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -64,46 +64,6 @@
;;; Profiles.
;;;
-(define %user-profile-directory
- (and=> (getenv "HOME")
- (cut string-append <> "/.guix-profile")))
-
-(define %profile-directory
- (string-append %state-directory "/profiles/"
- (or (and=> (or (getenv "USER")
- (getenv "LOGNAME"))
- (cut string-append "per-user/" <>))
- "default")))
-
-(define %current-profile
- ;; Call it `guix-profile', not `profile', to allow Guix profiles to
- ;; coexist with Nix profiles.
- (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.
- (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)))
-
-(define (user-friendly-profile profile)
- "Return either ~/.guix-profile if that's what PROFILE refers to, directly or
-indirectly, or PROFILE."
- (if (and %user-profile-directory
- (false-if-exception
- (string=? (readlink %user-profile-directory) profile)))
- %user-profile-directory
- profile))
-
(define (ensure-default-profile)
"Ensure the default profile symlink and directory exist and are writable."
- branch master updated (d6fb098 -> 77a1aac), Ludovic Courtès, 2018/06/09
- 05/10: ui: Avoid #:select'ing bindings introduced in the latest (guix build utils)., Ludovic Courtès, 2018/06/09
- 06/10: system: Honor ~/.config/guix/current in /etc/profile., Ludovic Courtès, 2018/06/09
- 07/10: profiles: Add '%current-profile', 'user-friendly-profile', & co.,
Ludovic Courtès <=
- 10/10: pull: Record the URL, branch, and commit as a manifest entry property., Ludovic Courtès, 2018/06/09
- 01/10: self: Produce a complete package with the 'guix' command., Ludovic Courtès, 2018/06/09
- 03/10: self: Compute and use locale data., Ludovic Courtès, 2018/06/09
- 08/10: packages: Add 'package-patched-vulnerabilities'., Ludovic Courtès, 2018/06/09
- 02/10: pull: Install the new Guix in a profile., Ludovic Courtès, 2018/06/09
- 04/10: self: Build the Info manual., Ludovic Courtès, 2018/06/09
- 09/10: profiles: Add 'properties' field to manifest entries., Ludovic Courtès, 2018/06/09