guix build: Set the build options early.

This fixes a bug whereby, with grafts leading to builds very early,
build options such as --substitute-urls would not be taken into account
yet.

Reported by Andreas Enge <andreas@enge.fr>.

* guix/scripts/build.scm (guix-build): Move 'opts' to the beginning.
Use 'with-store' instead of 'open-connection'.  Call
'set-build-options-from-command-line' right after 'with-store'.
This commit is contained in:
Ludovic Courtès 2016-03-04 17:50:30 +01:00
parent eda0522aab
commit c8f9f24776
1 changed files with 50 additions and 46 deletions

View File

@ -634,14 +634,19 @@ needed."
;;;
(define (guix-build . args)
(define opts
(parse-command-line args %options
(list %default-options)))
(with-error-handling
;; Ask for absolute file names so that .drv file names passed from the
;; user to 'read-derivation' are absolute when it returns.
(with-fluids ((%file-port-name-canonicalization 'absolute))
(let* ((opts (parse-command-line args %options
(list %default-options)))
(store (open-connection))
(mode (assoc-ref opts 'build-mode))
(with-store store
;; Set the build options before we do anything else.
(set-build-options-from-command-line store opts)
(let* ((mode (assoc-ref opts 'build-mode))
(drv (options->derivations store opts))
(urls (map (cut string-append <> "/log")
(if (assoc-ref opts 'substitutes?)
@ -660,7 +665,6 @@ needed."
(_ #f))
opts)))
(set-build-options-from-command-line store opts)
(unless (assoc-ref opts 'log-file?)
(show-what-to-build store drv
#:use-substitutes? (assoc-ref opts 'substitutes?)
@ -685,4 +689,4 @@ needed."
(map cdr
(derivation->output-paths drv)))
drv)
roots))))))))
roots)))))))))