summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-05-30 17:50:21 +0200
committerLudovic Courtès <ludo@gnu.org>2018-06-09 12:02:27 +0200
commit75e24d7b0e19ab2164aecb340e82d07d2b9714e7 (patch)
tree7e46b4d70532dc16482c57f94b6257b42600c04b
parent8a0d9bc8a3f153159d9e239a151c0fa98f1e12d8 (diff)
pull: Install the new Guix in a profile.
* guix/scripts/pull.scm (%pull-version): New variable. (build-from-source): Pass #:pull-version to BUILD. (whole-package-for-legacy, derivation->manifest-entry): New procedure. (build-and-install): Rewrite in terms of 'build-and-use-profile'. * guix/scripts/system.scm (maybe-suggest-running-guix-pull)[latest]: Switch to "/current". * scripts/guix.in (augment-load-paths!): Remove use of ~/.config/guix/latest. * build-aux/compile-as-derivation.scm: Replace "/guix/latest/" with "/current/share/guile/site/X.Y" * guix/scripts.scm (warn-about-old-distro)[age]: Check "/current" instead of "/latest". * doc/guix.texi (Invoking guix pull): Document it. * doc/contributing.texi (Running Guix Before It Is Installed): Remove footnote about abusing ~/.config/guix/latest.
-rw-r--r--build-aux/compile-as-derivation.scm3
-rw-r--r--doc/contributing.texi10
-rw-r--r--doc/guix.texi38
-rw-r--r--guix/scripts.scm4
-rw-r--r--guix/scripts/pull.scm79
-rw-r--r--guix/scripts/system.scm2
-rw-r--r--scripts/guix.in14
7 files changed, 94 insertions, 56 deletions
diff --git a/build-aux/compile-as-derivation.scm b/build-aux/compile-as-derivation.scm
index 2a45e71bb9d..59a84b14151 100644
--- a/build-aux/compile-as-derivation.scm
+++ b/build-aux/compile-as-derivation.scm
@@ -25,7 +25,8 @@
25 (and=> (or (getenv "XDG_CONFIG_HOME") 25 (and=> (or (getenv "XDG_CONFIG_HOME")
26 (and=> (getenv "HOME") 26 (and=> (getenv "HOME")
27 (cut string-append <> "/.config"))) 27 (cut string-append <> "/.config")))
28 (cut string-append <> "/guix/latest"))) 28 (cute string-append <> "/guix/current/share/guile/site/"
29 (effective-version))))
29 30
30(use-modules (guix) (guix ui) 31(use-modules (guix) (guix ui)
31 (guix git-download) 32 (guix git-download)
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 2792fe2b296..205c972aeae 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -155,15 +155,9 @@ The @command{pre-inst-env} script sets up all the environment variables
155necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}. 155necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
156 156
157Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the 157Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
158local source tree; it simply updates the @file{~/.config/guix/latest} 158local source tree; it simply updates the @file{~/.config/guix/current}
159symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if 159symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
160you want to upgrade your local source tree.@footnote{If you would like 160you want to upgrade your local source tree.
161to set up @command{guix} to use your Git checkout, you can point the
162@file{~/.config/guix/latest} symlink to your Git checkout directory.
163If you are the sole user of your system, you may also consider pointing
164the @file{/root/.config/guix/latest} symlink to point to
165@file{~/.config/guix/latest}; this way it will always use the same
166@command{guix} as your user does.}
167 161
168 162
169@node The Perfect Setup 163@node The Perfect Setup
diff --git a/doc/guix.texi b/doc/guix.texi
index 6ed4799dfc8..13b42f59f37 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2743,11 +2743,39 @@ Any user can update their Guix copy using @command{guix pull}, and the
2743effect is limited to the user who run @command{guix pull}. For 2743effect is limited to the user who run @command{guix pull}. For
2744instance, when user @code{root} runs @command{guix pull}, this has no 2744instance, when user @code{root} runs @command{guix pull}, this has no
2745effect on the version of Guix that user @code{alice} sees, and vice 2745effect on the version of Guix that user @code{alice} sees, and vice
2746versa@footnote{Under the hood, @command{guix pull} updates the 2746versa.
2747@file{~/.config/guix/latest} symbolic link to point to the latest Guix, 2747
2748and the @command{guix} command loads code from there. Currently, the 2748The result of running @command{guix pull} is a @dfn{profile} available
2749only way to roll back an invocation of @command{guix pull} is to 2749under @file{~/.config/guix/current} containing the latest Guix. Thus,
2750manually update this symlink to point to the previous Guix.}. 2750make sure to add it to the beginning of your search path so that you use
2751the latest version, and similarly for the Info manual
2752(@pxref{Documentation}):
2753
2754@example
2755export PATH="$HOME/.config/guix/current/bin:$PATH"
2756export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
2757@end example
2758
2759This @code{~/.config/guix/current} profile works like any other profile
2760created by @command{guix package} (@pxref{Invoking guix package}). That
2761is, you can list generations, roll back to the previous
2762generation---i.e., the previous Guix---and so on:
2763
2764@example
2765$ guix package -p ~/.config/guix/current -l
2766Generation 1 May 25 2018 10:06:41
2767 guix 221951a out /gnu/store/i4dfk7vw5k112s49jrhl6hwsfnh6wr7l-guix-221951af4
2768
2769Generation 2 May 27 2018 19:07:47
2770 + guix 2fbae00 out /gnu/store/44cv9hyvxg34xf5kblf5dz57hc52y4bm-guix-2fbae006f
2771 - guix 221951a out /gnu/store/i4dfk7vw5k112s49jrhl6hwsfnh6wr7l-guix-221951af4
2772
2773Generation 3 May 30 2018 16:11:39 (current)
2774 + guix a076f19 out /gnu/store/332czkicwwg6lc3x4aqbw5q2mq12s7fj-guix-a076f1990
2775 - guix 2fbae00 out /gnu/store/44cv9hyvxg34xf5kblf5dz57hc52y4bm-guix-2fbae006f
2776$ guix package -p ~/.config/guix/current --roll-back
2777switched from generation 3 to 2
2778@end example
2751 2779
2752The @command{guix pull} command is usually invoked with no arguments, 2780The @command{guix pull} command is usually invoked with no arguments,
2753but it supports the following options: 2781but it supports the following options:
diff --git a/guix/scripts.scm b/guix/scripts.scm
index 4a7ae7baa31..4cbbbeb96f9 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com> 3;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
4;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com> 4;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
5;;; 5;;;
@@ -170,7 +170,7 @@ Show what and how will/would be built."
170 (define age 170 (define age
171 (match (false-if-not-found 171 (match (false-if-not-found
172 (lstat (string-append (config-directory #:ensure? #f) 172 (lstat (string-append (config-directory #:ensure? #f)
173 "/latest"))) 173 "/current")))
174 (#f #f) 174 (#f #f)
175 (stat (- (time-second (current-time time-utc)) 175 (stat (- (time-second (current-time time-utc))
176 (stat:mtime stat))))) 176 (stat:mtime stat)))))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 64c2196e03f..c5ceebccb60 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com> 3;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
@@ -25,10 +25,15 @@
25 #:use-module (guix config) 25 #:use-module (guix config)
26 #:use-module (guix packages) 26 #:use-module (guix packages)
27 #:use-module (guix derivations) 27 #:use-module (guix derivations)
28 #:use-module (guix profiles)
28 #:use-module (guix gexp) 29 #:use-module (guix gexp)
29 #:use-module (guix grafts) 30 #:use-module (guix grafts)
30 #:use-module (guix monads) 31 #:use-module (guix monads)
31 #:use-module (guix scripts build) 32 #:use-module (guix scripts build)
33 #:autoload (guix self) (whole-package)
34 #:autoload (gnu packages ssh) (guile-ssh)
35 #:autoload (gnu packages tls) (gnutls)
36 #:use-module ((guix scripts package) #:select (build-and-use-profile))
32 #:use-module ((guix build utils) 37 #:use-module ((guix build utils)
33 #:select (with-directory-excursion delete-file-recursively)) 38 #:select (with-directory-excursion delete-file-recursively))
34 #:use-module ((guix build download) 39 #:use-module ((guix build download)
@@ -158,6 +163,12 @@ Download and deploy the latest version of Guix.\n"))
158 ;; a makefile, and, similarly, is intended to always keep this name. 163 ;; a makefile, and, similarly, is intended to always keep this name.
159 "build-aux/build-self.scm") 164 "build-aux/build-self.scm")
160 165
166(define %pull-version
167 ;; This is the version of the 'guix pull' protocol. It specifies what's
168 ;; expected from %SELF-BUILD-FILE. The initial version ("0") was when we'd
169 ;; place a set of compiled Guile modules in ~/.config/guix/latest.
170 1)
171
161(define* (build-from-source source 172(define* (build-from-source source
162 #:key verbose? commit) 173 #:key verbose? commit)
163 "Return a derivation to build Guix from SOURCE, using the self-build script 174 "Return a derivation to build Guix from SOURCE, using the self-build script
@@ -170,35 +181,51 @@ contained therein. Use COMMIT as the version string."
170 (build (primitive-load script))) 181 (build (primitive-load script)))
171 ;; BUILD must be a monadic procedure of at least one argument: the source 182 ;; BUILD must be a monadic procedure of at least one argument: the source
172 ;; tree. 183 ;; tree.
173 (build source #:verbose? verbose? #:version commit))) 184 ;;
185 ;; Note: BUILD can return #f if it does not support %PULL-VERSION. In the
186 ;; future we'll fall back to a previous version of the protocol when that
187 ;; happens.
188 (build source #:verbose? verbose? #:version commit
189 #:pull-version %pull-version)))
190
191(define (whole-package-for-legacy name modules)
192 "Return a full-blown Guix package for MODULES, a derivation that builds Guix
193modules in the old ~/.config/guix/latest style."
194 (whole-package name modules
195
196 ;; In the "old style", %SELF-BUILD-FILE would simply return a
197 ;; derivation that builds modules. We have to infer what the
198 ;; dependencies of these modules were.
199 (list guile-json guile-git guile-bytestructures
200 guile-ssh gnutls)))
201
202(define (derivation->manifest-entry drv commit)
203 "Return a manifest entry for DRV, which represents Guix at COMMIT."
204 (mbegin %store-monad
205 (what-to-build (list drv))
206 (built-derivations (list drv))
207 (let ((out (derivation->output-path drv)))
208 (return (manifest-entry
209 (name "guix")
210 (version (string-take commit 7))
211 (item (if (file-exists? (string-append out "/bin/guix"))
212 drv
213 (whole-package-for-legacy (string-append name "-"
214 version)
215 drv))))))))
174 216
175(define* (build-and-install source config-dir 217(define* (build-and-install source config-dir
176 #:key verbose? commit) 218 #:key verbose? commit)
177 "Build the tool from SOURCE, and install it in CONFIG-DIR." 219 "Build the tool from SOURCE, and install it in CONFIG-DIR."
178 (mlet* %store-monad ((source (build-from-source source 220 (define update-profile
179 #:commit commit 221 (store-lift build-and-use-profile))
180 #:verbose? verbose?)) 222
181 (source-dir -> (derivation->output-path source)) 223 (mlet* %store-monad ((drv (build-from-source source
182 (to-do? (what-to-build (list source))) 224 #:commit commit
183 (built? (built-derivations (list source)))) 225 #:verbose? verbose?))
184 ;; Always update the 'latest' symlink, regardless of whether SOURCE was 226 (entry (derivation->manifest-entry drv commit)))
185 ;; already built or not. 227 (update-profile (string-append config-dir "/current")
186 (if built? 228 (manifest (list entry)))))
187 (mlet* %store-monad
188 ((latest -> (string-append config-dir "/latest"))
189 (done (indirect-root-added latest)))
190 (if (and (file-exists? latest)
191 (string=? (readlink latest) source-dir))
192 (begin
193 (display (G_ "Guix already up to date\n"))
194 (return #t))
195 (begin
196 (switch-symlinks latest source-dir)
197 (format #t
198 (G_ "updated ~a successfully deployed under `~a'~%")
199 %guix-package-name latest)
200 (return #t))))
201 (leave (G_ "failed to update Guix, check the build log~%")))))
202 229
203(define (honor-lets-encrypt-certificates! store) 230(define (honor-lets-encrypt-certificates! store)
204 "Tell Guile-Git to use the Let's Encrypt certificates." 231 "Tell Guile-Git to use the Let's Encrypt certificates."
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 766cab1aad5..14be8ff8cfd 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -740,7 +740,7 @@ checking this by themselves in their 'check' procedure."
740 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html> for 740 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html> for
741 ;; a discussion. 741 ;; a discussion.
742 (define latest 742 (define latest
743 (string-append (config-directory) "/latest")) 743 (string-append (config-directory) "/current"))
744 744
745 (unless (file-exists? latest) 745 (unless (file-exists? latest)
746 (warning (G_ "~a not found: 'guix pull' was never run~%") latest) 746 (warning (G_ "~a not found: 'guix pull' was never run~%") latest)
diff --git a/scripts/guix.in b/scripts/guix.in
index d1c12eae5c4..0a3ab1f64df 100644
--- a/scripts/guix.in
+++ b/scripts/guix.in
@@ -23,25 +23,13 @@
23;; IMPORTANT: We must avoid loading any modules from Guix here, 23;; IMPORTANT: We must avoid loading any modules from Guix here,
24;; because we need to adjust the guile load paths first. 24;; because we need to adjust the guile load paths first.
25;; It's okay to import modules from core Guile though. 25;; It's okay to import modules from core Guile though.
26(use-modules (srfi srfi-26))
27 26
28(define-syntax-rule (push! elt v) (set! v (cons elt v))) 27(define-syntax-rule (push! elt v) (set! v (cons elt v)))
29 28
30(define (augment-load-paths!) 29(define (augment-load-paths!)
31 ;; Add installed modules to load-path. 30 ;; Add installed modules to load-path.
32 (push! "@guilemoduledir@" %load-path) 31 (push! "@guilemoduledir@" %load-path)
33 (push! "@guileobjectdir@" %load-compiled-path) 32 (push! "@guileobjectdir@" %load-compiled-path))
34
35 ;; Add modules fetched by 'guix pull' to load-path.
36 (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME")
37 (and=> (getenv "HOME")
38 (cut string-append <> "/.config")))
39 (cut string-append <> "/guix/latest"))))
40 (when (and=> updates-dir file-exists?)
41 ;; XXX: Currently 'guix pull' puts both .scm and .go files in
42 ;; UPDATES-DIR.
43 (push! updates-dir %load-path)
44 (push! updates-dir %load-compiled-path))))
45 33
46(define* (main #:optional (args (command-line))) 34(define* (main #:optional (args (command-line)))
47 (unless (getenv "GUIX_UNINSTALLED") 35 (unless (getenv "GUIX_UNINSTALLED")