guix build: Separate transformation options.
[jackhill/guix/guix.git] / guix / scripts / build.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f4953019 2;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
dc5669cd 3;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
14a1c319 4;;;
233e7676 5;;; This file is part of GNU Guix.
14a1c319 6;;;
233e7676 7;;; GNU Guix is free software; you can redistribute it and/or modify it
14a1c319
LC
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
233e7676 12;;; GNU Guix is distributed in the hope that it will be useful, but
14a1c319
LC
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
233e7676 18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
14a1c319 19
e49951eb 20(define-module (guix scripts build)
073c34d7 21 #:use-module (guix ui)
88981dd3 22 #:use-module (guix scripts)
14a1c319
LC
23 #:use-module (guix store)
24 #:use-module (guix derivations)
25 #:use-module (guix packages)
07783858 26 #:use-module (guix utils)
ac5de156 27 #:use-module (guix monads)
56b82106 28 #:use-module (guix gexp)
3f208ad7 29 #:autoload (guix http-client) (http-fetch http-get-error?)
14a1c319
LC
30 #:use-module (ice-9 format)
31 #:use-module (ice-9 match)
dc5669cd 32 #:use-module (ice-9 vlist)
14a1c319 33 #:use-module (srfi srfi-1)
5401dd75 34 #:use-module (srfi srfi-11)
14a1c319 35 #:use-module (srfi srfi-26)
07783858 36 #:use-module (srfi srfi-34)
14a1c319 37 #:use-module (srfi srfi-37)
300868ba 38 #:autoload (gnu packages) (specification->package %package-module-path)
7f3673f2 39 #:autoload (guix download) (download-to-store)
257b9341 40 #:export (%standard-build-options
e7fc17b5 41 set-build-options-from-command-line
2d977638 42 set-build-options-from-command-line*
e7fc17b5 43 show-build-options-help
88ad6ded
LC
44
45 %transformation-options
629a064f 46 options->transformation
88ad6ded 47 show-transformation-options-help
e7fc17b5 48
760c60d6 49 guix-build))
14a1c319 50
3f208ad7
LC
51(define %default-log-urls
52 ;; Default base URLs for build logs.
53 '("http://hydra.gnu.org/log"))
54
55;; XXX: The following procedure cannot be in (guix store) because of the
56;; dependency on (guix derivations).
57(define* (log-url store file #:key (base-urls %default-log-urls))
58 "Return a URL under one of the BASE-URLS where a build log for FILE can be
59found. Return #f if no build log was found."
60 (define (valid-url? url)
61 ;; Probe URL and return #t if it is accessible.
62 (guard (c ((http-get-error? c) #f))
63 (close-port (http-fetch url #:buffered? #f))
64 #t))
65
66 (define (find-url file)
67 (let ((base (basename file)))
68 (any (lambda (base-url)
69 (let ((url (string-append base-url "/" base)))
70 (and (valid-url? url) url)))
71 base-urls)))
72
73 (cond ((derivation-path? file)
74 (catch 'system-error
75 (lambda ()
76 ;; Usually we'll have more luck with the output file name since
77 ;; the deriver that was used by the server could be different, so
78 ;; try one of the output file names.
79 (let ((drv (call-with-input-file file read-derivation)))
80 (or (find-url (derivation->output-path drv))
81 (find-url file))))
82 (lambda args
83 ;; As a last resort, try the .drv.
84 (if (= ENOENT (system-error-errno args))
85 (find-url file)
86 (apply throw args)))))
87 (else
88 (find-url file))))
89
81fa80b2
LC
90(define (register-root store paths root)
91 "Register ROOT as an indirect GC root for all of PATHS."
92 (let* ((root (string-append (canonicalize-path (dirname root))
93 "/" root)))
94 (catch 'system-error
95 (lambda ()
96 (match paths
97 ((path)
98 (symlink path root)
99 (add-indirect-root store root))
100 ((paths ...)
101 (fold (lambda (path count)
102 (let ((root (string-append root
103 "-"
104 (number->string count))))
105 (symlink path root)
106 (add-indirect-root store root))
107 (+ 1 count))
108 0
109 paths))))
110 (lambda args
111 (leave (_ "failed to create GC root `~a': ~a~%")
112 root (strerror (system-error-errno args)))))))
113
7f3673f2
LC
114(define (package-with-source store p uri)
115 "Return a package based on P but with its source taken from URI. Extract
116the new package's version number from URI."
117 (define (numeric-extension? file-name)
118 ;; Return true if FILE-NAME ends with digits.
119 (string-every char-set:hex-digit (file-extension file-name)))
120
121 (define (tarball-base-name file-name)
122 ;; Return the "base" of FILE-NAME, removing '.tar.gz' or similar
123 ;; extensions.
124 ;; TODO: Factorize.
a43b55f1
LC
125 (cond ((not (file-extension file-name))
126 file-name)
127 ((numeric-extension? file-name)
7f3673f2
LC
128 file-name)
129 ((string=? (file-extension file-name) "tar")
130 (file-sans-extension file-name))
a43b55f1
LC
131 ((file-extension file-name)
132 (tarball-base-name (file-sans-extension file-name)))
7f3673f2 133 (else
a43b55f1 134 file-name)))
7f3673f2
LC
135
136 (let ((base (tarball-base-name (basename uri))))
137 (let-values (((name version)
138 (package-name->name+version base)))
139 (package (inherit p)
140 (version (or version (package-version p)))
a43b55f1
LC
141
142 ;; Use #:recursive? #t to allow for directories.
143 (source (download-to-store store uri
144 #:recursive? #t))))))
7f3673f2 145
14a1c319 146\f
88ad6ded
LC
147;;;
148;;; Transformations.
149;;;
150
151(define (transform-package-source sources)
152 "Return a transformation procedure that replaces package sources with the
153matching URIs given in SOURCES."
154 (define new-sources
155 (map (lambda (uri)
156 (cons (package-name->name+version (basename uri))
157 uri))
158 sources))
159
160 (lambda (store obj)
161 (let loop ((sources new-sources)
162 (result '()))
163 (match obj
164 ((? package? p)
165 (let ((source (assoc-ref sources (package-name p))))
166 (if source
167 (package-with-source store p source)
168 p)))
169 (_
170 obj)))))
171
172(define %transformations
173 ;; Transformations that can be applied to things to build. The car is the
174 ;; key used in the option alist, and the cdr is the transformation
175 ;; procedure; it is called with two arguments: the store, and a list of
176 ;; things to build.
177 `((with-source . ,transform-package-source)))
178
179(define %transformation-options
180 ;; The command-line interface to the above transformations.
181 (list (option '("with-source") #t #f
182 (lambda (opt name arg result . rest)
183 (apply values
184 (cons (alist-cons 'with-source arg result)
185 rest))))))
186
187(define (show-transformation-options-help)
188 (display (_ "
189 --with-source=SOURCE
190 use SOURCE when building the corresponding package")))
191
192
193(define (options->transformation opts)
194 "Return a procedure that, when passed an object to build (package,
195derivation, etc.), applies the transformations specified by OPTS."
196 (define applicable
197 ;; List of applicable transformations as symbol/procedure pairs.
198 (filter-map (match-lambda
199 ((key . transform)
200 (match (filter-map (match-lambda
201 ((k . arg)
202 (and (eq? k key) arg)))
203 opts)
204 (() #f)
205 (args (cons key (transform args))))))
206 %transformations))
207
208 (lambda (store obj)
209 (fold (match-lambda*
210 (((name . transform) obj)
211 (let ((new (transform store obj)))
212 (when (eq? new obj)
213 (warning (_ "transformation '~a' had no effect on ~a~%")
214 name
215 (if (package? obj)
216 (package-full-name obj)
217 obj)))
218 new)))
219 obj
220 applicable)))
221
222\f
14a1c319 223;;;
e7fc17b5 224;;; Standard command-line build options.
14a1c319
LC
225;;;
226
e7fc17b5
LC
227(define (show-build-options-help)
228 "Display on the current output port help about the standard command-line
229options handled by 'set-build-options-from-command-line', and listed in
230'%standard-build-options'."
300868ba
LC
231 (display (_ "
232 -L, --load-path=DIR prepend DIR to the package module search path"))
609354bf 233 (display (_ "
14a1c319
LC
234 -K, --keep-failed keep build tree of failed builds"))
235 (display (_ "
f4953019
LC
236 -k, --keep-going keep going when some of the derivations fail"))
237 (display (_ "
14a1c319 238 -n, --dry-run do not build the derivations"))
56b1f4b7
LC
239 (display (_ "
240 --fallback fall back to building when the substituter fails"))
1c3972da 241 (display (_ "
692c6c15 242 --no-substitutes build instead of resorting to pre-built substitutes"))
f8a8e0fe
LC
243 (display (_ "
244 --substitute-urls=URLS
245 fetch substitute from URLS if they are authorized"))
425b0bfc
LC
246 (display (_ "
247 --no-build-hook do not attempt to offload builds via the build hook"))
969e678e
LC
248 (display (_ "
249 --max-silent-time=SECONDS
250 mark the build as failed after SECONDS of silence"))
002622b6
LC
251 (display (_ "
252 --timeout=SECONDS mark the build as failed after SECONDS of activity"))
07ab4bf1
LC
253 (display (_ "
254 --verbosity=LEVEL use the given verbosity LEVEL"))
5b74fe06
LC
255 (display (_ "
256 --rounds=N build N times in a row to detect non-determinism"))
bf421152 257 (display (_ "
f6526eb3
LC
258 -c, --cores=N allow the use of up to N CPU cores for the build"))
259 (display (_ "
260 -M, --max-jobs=N allow at most N build jobs")))
14a1c319 261
e7fc17b5
LC
262(define (set-build-options-from-command-line store opts)
263 "Given OPTS, an alist as returned by 'args-fold' given
264'%standard-build-options', set the corresponding build options on STORE."
265 ;; TODO: Add more options.
266 (set-build-options store
267 #:keep-failed? (assoc-ref opts 'keep-failed?)
f4953019 268 #:keep-going? (assoc-ref opts 'keep-going?)
5b74fe06 269 #:rounds (assoc-ref opts 'rounds)
e7fc17b5 270 #:build-cores (or (assoc-ref opts 'cores) 0)
f6526eb3 271 #:max-build-jobs (or (assoc-ref opts 'max-jobs) 1)
e7fc17b5
LC
272 #:fallback? (assoc-ref opts 'fallback?)
273 #:use-substitutes? (assoc-ref opts 'substitutes?)
fb4bf72b 274 #:substitute-urls (assoc-ref opts 'substitute-urls)
e7fc17b5
LC
275 #:use-build-hook? (assoc-ref opts 'build-hook?)
276 #:max-silent-time (assoc-ref opts 'max-silent-time)
002622b6 277 #:timeout (assoc-ref opts 'timeout)
b6b097ac 278 #:print-build-trace (assoc-ref opts 'print-build-trace?)
e7fc17b5 279 #:verbosity (assoc-ref opts 'verbosity)))
14a1c319 280
2d977638
DT
281(define set-build-options-from-command-line*
282 (store-lift set-build-options-from-command-line))
283
e7fc17b5
LC
284(define %standard-build-options
285 ;; List of standard command-line options for tools that build something.
300868ba
LC
286 (list (option '(#\L "load-path") #t #f
287 (lambda (opt name arg result . rest)
288 ;; XXX: Imperatively modify the search paths.
289 (%package-module-path (cons arg (%package-module-path)))
223d7939 290 (%patch-path (cons arg (%patch-path)))
300868ba
LC
291 (set! %load-path (cons arg %load-path))
292 (set! %load-compiled-path (cons arg %load-compiled-path))
293
294 (apply values (cons result rest))))
295 (option '(#\K "keep-failed") #f #f
dd67b429
LC
296 (lambda (opt name arg result . rest)
297 (apply values
298 (alist-cons 'keep-failed? #t result)
299 rest)))
f4953019
LC
300 (option '(#\k "keep-going") #f #f
301 (lambda (opt name arg result . rest)
302 (apply values
303 (alist-cons 'keep-going? #t result)
304 rest)))
5b74fe06
LC
305 (option '("rounds") #t #f
306 (lambda (opt name arg result . rest)
307 (apply values
308 (alist-cons 'rounds (string->number* arg)
309 result)
310 rest)))
56b1f4b7 311 (option '("fallback") #f #f
dd67b429
LC
312 (lambda (opt name arg result . rest)
313 (apply values
314 (alist-cons 'fallback? #t
315 (alist-delete 'fallback? result))
316 rest)))
692c6c15 317 (option '("no-substitutes") #f #f
dd67b429
LC
318 (lambda (opt name arg result . rest)
319 (apply values
320 (alist-cons 'substitutes? #f
321 (alist-delete 'substitutes? result))
322 rest)))
f8a8e0fe
LC
323 (option '("substitute-urls") #t #f
324 (lambda (opt name arg result . rest)
325 (apply values
326 (alist-cons 'substitute-urls
327 (string-tokenize arg)
328 (alist-delete 'substitute-urls result))
329 rest)))
425b0bfc 330 (option '("no-build-hook") #f #f
dd67b429
LC
331 (lambda (opt name arg result . rest)
332 (apply values
333 (alist-cons 'build-hook? #f
334 (alist-delete 'build-hook? result))
335 rest)))
969e678e 336 (option '("max-silent-time") #t #f
dd67b429
LC
337 (lambda (opt name arg result . rest)
338 (apply values
339 (alist-cons 'max-silent-time (string->number* arg)
340 result)
341 rest)))
002622b6
LC
342 (option '("timeout") #t #f
343 (lambda (opt name arg result . rest)
344 (apply values
345 (alist-cons 'timeout (string->number* arg) result)
346 rest)))
07ab4bf1 347 (option '("verbosity") #t #f
dd67b429 348 (lambda (opt name arg result . rest)
07ab4bf1 349 (let ((level (string->number arg)))
dd67b429
LC
350 (apply values
351 (alist-cons 'verbosity level
352 (alist-delete 'verbosity result))
353 rest))))
e7fc17b5 354 (option '(#\c "cores") #t #f
dd67b429 355 (lambda (opt name arg result . rest)
e7fc17b5
LC
356 (let ((c (false-if-exception (string->number arg))))
357 (if c
dd67b429 358 (apply values (alist-cons 'cores c result) rest)
f6526eb3
LC
359 (leave (_ "not a number: '~a' option argument: ~a~%")
360 name arg)))))
361 (option '(#\M "max-jobs") #t #f
362 (lambda (opt name arg result . rest)
363 (let ((c (false-if-exception (string->number arg))))
364 (if c
365 (apply values (alist-cons 'max-jobs c result) rest)
366 (leave (_ "not a number: '~a' option argument: ~a~%")
367 name arg)))))))
e7fc17b5
LC
368
369\f
370;;;
371;;; Command-line options.
372;;;
373
374(define %default-options
375 ;; Alist of default option values.
376 `((system . ,(%current-system))
a8d65643 377 (build-mode . ,(build-mode normal))
05962f29 378 (graft? . #t)
e7fc17b5
LC
379 (substitutes? . #t)
380 (build-hook? . #t)
b6b097ac 381 (print-build-trace? . #t)
e7fc17b5
LC
382 (max-silent-time . 3600)
383 (verbosity . 0)))
384
385(define (show-help)
386 (display (_ "Usage: guix build [OPTION]... PACKAGE-OR-DERIVATION...
387Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
388 (display (_ "
389 -e, --expression=EXPR build the package or derivation EXPR evaluates to"))
390 (display (_ "
34a1783f
DT
391 -f, --file=FILE build the package or derivation that the code within
392 FILE evaluates to"))
393 (display (_ "
e7fc17b5
LC
394 -S, --source build the packages' source derivations"))
395 (display (_ "
2087023d 396 --sources[=TYPE] build source derivations; TYPE may optionally be one
2cdfe13d
EB
397 of \"package\", \"all\" (default), or \"transitive\""))
398 (display (_ "
e7fc17b5
LC
399 -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
400 (display (_ "
401 --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
05962f29
LC
402 (display (_ "
403 --no-grafts do not graft packages"))
e7fc17b5
LC
404 (display (_ "
405 -d, --derivations return the derivation paths of the given packages"))
a8d65643
LC
406 (display (_ "
407 --check rebuild items to check for non-determinism issues"))
e7fc17b5
LC
408 (display (_ "
409 -r, --root=FILE make FILE a symlink to the result, and register it
410 as a garbage collector root"))
411 (display (_ "
412 --log-file return the log file names for the given derivations"))
413 (newline)
414 (show-build-options-help)
415 (newline)
88ad6ded
LC
416 (show-transformation-options-help)
417 (newline)
e7fc17b5
LC
418 (display (_ "
419 -h, --help display this help and exit"))
420 (display (_ "
421 -V, --version display version information and exit"))
422 (newline)
423 (show-bug-report-information))
424
425(define %options
426 ;; Specifications of the command-line options.
427 (cons* (option '(#\h "help") #f #f
428 (lambda args
429 (show-help)
430 (exit 0)))
431 (option '(#\V "version") #f #f
432 (lambda args
433 (show-version-and-exit "guix build")))
e7fc17b5
LC
434 (option '(#\S "source") #f #f
435 (lambda (opt name arg result)
2cdfe13d
EB
436 (alist-cons 'source #t result)))
437 (option '("sources") #f #t
438 (lambda (opt name arg result)
439 (match arg
440 ("package"
441 (alist-cons 'source #t result))
442 ((or "all" #f)
443 (alist-cons 'source package-direct-sources result))
444 ("transitive"
445 (alist-cons 'source package-transitive-sources result))
446 (else
447 (leave (_ "invalid argument: '~a' option argument: ~a, ~
448must be one of 'package', 'all', or 'transitive'~%")
449 name arg)))))
88ad6ded
LC
450 (option '("check") #f #f
451 (lambda (opt name arg result . rest)
452 (apply values
453 (alist-cons 'build-mode (build-mode check)
454 result)
455 rest)))
e7fc17b5
LC
456 (option '(#\s "system") #t #f
457 (lambda (opt name arg result)
458 (alist-cons 'system arg
459 (alist-delete 'system result eq?))))
460 (option '("target") #t #f
461 (lambda (opt name arg result)
462 (alist-cons 'target arg
463 (alist-delete 'target result eq?))))
464 (option '(#\d "derivations") #f #f
465 (lambda (opt name arg result)
466 (alist-cons 'derivations-only? #t result)))
467 (option '(#\e "expression") #t #f
468 (lambda (opt name arg result)
469 (alist-cons 'expression arg result)))
34a1783f
DT
470 (option '(#\f "file") #t #f
471 (lambda (opt name arg result)
472 (alist-cons 'file arg result)))
e7fc17b5
LC
473 (option '(#\n "dry-run") #f #f
474 (lambda (opt name arg result)
475 (alist-cons 'dry-run? #t result)))
476 (option '(#\r "root") #t #f
477 (lambda (opt name arg result)
478 (alist-cons 'gc-root arg result)))
479 (option '("log-file") #f #f
480 (lambda (opt name arg result)
481 (alist-cons 'log-file? #t result)))
05962f29
LC
482 (option '("no-grafts") #f #f
483 (lambda (opt name arg result)
484 (alist-cons 'graft? #f
485 (alist-delete 'graft? result eq?))))
e7fc17b5 486
88ad6ded
LC
487 (append %transformation-options
488 %standard-build-options)))
14a1c319 489
64ec0e29
LC
490(define (options->things-to-build opts)
491 "Read the arguments from OPTS and return a list of high-level objects to
492build---packages, gexps, derivations, and so on."
20464dde
LC
493 (define (validate-type x)
494 (unless (or (package? x) (derivation? x) (gexp? x) (procedure? x))
495 (leave (_ "~s: not something we can build~%") x)))
496
497 (define (ensure-list x)
498 (let ((lst (match x
499 ((x ...) x)
500 (x (list x)))))
501 (for-each validate-type lst)
502 lst))
64ec0e29
LC
503
504 (append-map (match-lambda
505 (('argument . (? string? spec))
506 (cond ((derivation-path? spec)
507 (list (call-with-input-file spec read-derivation)))
508 ((store-path? spec)
509 ;; Nothing to do; maybe for --log-file.
510 '())
511 (else
512 (list (specification->package spec)))))
513 (('file . file)
514 (ensure-list (load* file (make-user-module '()))))
515 (('expression . str)
516 (ensure-list (read/eval str)))
517 (('argument . (? derivation? drv))
518 drv)
64ec0e29
LC
519 (_ '()))
520 opts))
521
81fa80b2
LC
522(define (options->derivations store opts)
523 "Given OPTS, the result of 'args-fold', return a list of derivations to
524build."
64ec0e29
LC
525 (define transform
526 (options->transformation opts))
527
81fa80b2
LC
528 (define package->derivation
529 (match (assoc-ref opts 'target)
530 (#f package-derivation)
531 (triplet
532 (cut package-cross-derivation <> <> triplet <>))))
533
2cdfe13d 534 (define src (assoc-ref opts 'source))
64ec0e29 535 (define system (assoc-ref opts 'system))
05962f29 536 (define graft? (assoc-ref opts 'graft?))
81fa80b2 537
05962f29 538 (parameterize ((%graft? graft?))
64ec0e29
LC
539 (append-map (match-lambda
540 ((? package? p)
541 (match src
542 (#f
543 (list (package->derivation store p system)))
544 (#t
545 (let ((s (package-source p)))
546 (list (package-source-derivation store s))))
547 (proc
548 (map (cut package-source-derivation store <>)
549 (proc p)))))
550 ((? derivation? drv)
551 (list drv))
552 ((? procedure? proc)
553 (list (run-with-store store
554 (mbegin %store-monad
555 (set-guile-for-build (default-guile))
556 (proc))
557 #:system system)))
558 ((? gexp? gexp)
559 (list (run-with-store store
560 (mbegin %store-monad
561 (set-guile-for-build (default-guile))
562 (gexp->derivation "gexp" gexp
563 #:system system))))))
629a064f
LC
564 (map (cut transform store <>)
565 (options->things-to-build opts)))))
64ec0e29 566
841cb43c
LC
567(define (show-build-log store file urls)
568 "Show the build log for FILE, falling back to remote logs from URLS if
569needed."
570 (let ((log (or (log-file store file)
571 (log-url store file #:base-urls urls))))
572 (if log
573 (format #t "~a~%" log)
574 (leave (_ "no build log for '~a'~%") file))))
575
14a1c319
LC
576\f
577;;;
578;;; Entry point.
579;;;
580
581(define (guix-build . args)
073c34d7 582 (with-error-handling
bf421152
LC
583 ;; Ask for absolute file names so that .drv file names passed from the
584 ;; user to 'read-derivation' are absolute when it returns.
585 (with-fluids ((%file-port-name-canonicalization 'absolute))
b3f21389
LC
586 (let* ((opts (parse-command-line args %options
587 (list %default-options)))
81fa80b2 588 (store (open-connection))
a8d65643 589 (mode (assoc-ref opts 'build-mode))
81fa80b2 590 (drv (options->derivations store opts))
3f208ad7
LC
591 (urls (map (cut string-append <> "/log")
592 (if (assoc-ref opts 'substitutes?)
593 (or (assoc-ref opts 'substitute-urls)
fb4bf72b
LC
594 ;; XXX: This does not necessarily match the
595 ;; daemon's substitute URLs.
3f208ad7
LC
596 %default-substitute-urls)
597 '())))
841cb43c
LC
598 (items (filter-map (match-lambda
599 (('argument . (? store-path? file))
600 file)
601 (_ #f))
602 opts))
81fa80b2 603 (roots (filter-map (match-lambda
841cb43c
LC
604 (('gc-root . root) root)
605 (_ #f))
81fa80b2 606 opts)))
9bb2b96a 607
e7fc17b5 608 (set-build-options-from-command-line store opts)
bdff90a1
LC
609 (unless (assoc-ref opts 'log-file?)
610 (show-what-to-build store drv
611 #:use-substitutes? (assoc-ref opts 'substitutes?)
a8d65643
LC
612 #:dry-run? (assoc-ref opts 'dry-run?)
613 #:mode mode))
bdff90a1 614
81fa80b2 615 (cond ((assoc-ref opts 'log-file?)
841cb43c 616 (for-each (cut show-build-log store <> urls)
81fa80b2
LC
617 (delete-duplicates
618 (append (map derivation-file-name drv)
841cb43c 619 items))))
81fa80b2
LC
620 ((assoc-ref opts 'derivations-only?)
621 (format #t "~{~a~%~}" (map derivation-file-name drv))
622 (for-each (cut register-root store <> <>)
623 (map (compose list derivation-file-name) drv)
624 roots))
625 ((not (assoc-ref opts 'dry-run?))
a8d65643 626 (and (build-derivations store drv mode)
fa394eb9 627 (for-each show-derivation-outputs drv)
81fa80b2
LC
628 (for-each (cut register-root store <> <>)
629 (map (lambda (drv)
630 (map cdr
631 (derivation->output-paths drv)))
632 drv)
633 roots))))))))