guix system: Warn against missing 'guix pull'.

Suggested by Leo Famulari and others.

* guix/scripts/system.scm (maybe-suggest-running-guix-pull): New
procedure.
(perform-action): Call it when ACTION is 'reconfigure.
This commit is contained in:
Ludovic Courtès 2016-03-28 22:49:42 +02:00
parent e2f41133e9
commit 7f949db03e
1 changed files with 18 additions and 0 deletions

View File

@ -482,6 +482,21 @@ PATTERN, a string. When PATTERN is #f, display all the system generations."
((disk-image) ((disk-image)
(system-disk-image os #:disk-image-size image-size)))) (system-disk-image os #:disk-image-size image-size))))
(define (maybe-suggest-running-guix-pull)
"Suggest running 'guix pull' if this has never been done before."
;; The reason for this is that the 'guix' binding that we see here comes
;; from either ~/.config/latest or, if it's missing, from the
;; globally-installed Guix, which is necessarily older. See
;; <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html> for
;; a discussion.
(define latest
(string-append (config-directory) "/latest"))
(unless (file-exists? latest)
(warning (_ "~a not found: 'guix pull' was never run~%") latest)
(warning (_ "Consider running 'guix pull' before 'reconfigure'.~%"))
(warning (_ "Failing to do that may downgrade your system!~%"))))
(define* (perform-action action os (define* (perform-action action os
#:key grub? dry-run? derivations-only? #:key grub? dry-run? derivations-only?
use-substitutes? device target use-substitutes? device target
@ -498,6 +513,9 @@ building anything."
(define println (define println
(cut format #t "~a~%" <>)) (cut format #t "~a~%" <>))
(when (eq? action 'reconfigure)
(maybe-suggest-running-guix-pull))
(mlet* %store-monad (mlet* %store-monad
((sys (system-derivation-for-action os action ((sys (system-derivation-for-action os action
#:image-size image-size #:image-size image-size