Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / tests / derivations.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (unsetenv "http_proxy")
20
21 (define-module (test-derivations)
22 #:use-module (guix derivations)
23 #:use-module (guix grafts)
24 #:use-module (guix store)
25 #:use-module (guix utils)
26 #:use-module (gcrypt hash)
27 #:use-module (guix base32)
28 #:use-module (guix tests)
29 #:use-module (guix tests http)
30 #:use-module ((guix packages) #:select (package-derivation base32))
31 #:use-module ((guix build utils) #:select (executable-file?))
32 #:use-module (gnu packages bootstrap)
33 #:use-module ((gnu packages guile) #:select (guile-1.8))
34 #:use-module (srfi srfi-1)
35 #:use-module (srfi srfi-11)
36 #:use-module (srfi srfi-26)
37 #:use-module (srfi srfi-34)
38 #:use-module (srfi srfi-64)
39 #:use-module (rnrs io ports)
40 #:use-module (rnrs bytevectors)
41 #:use-module (web uri)
42 #:use-module (ice-9 rdelim)
43 #:use-module (ice-9 regex)
44 #:use-module (ice-9 ftw)
45 #:use-module (ice-9 match))
46
47 (define %store
48 (open-connection-for-tests))
49
50 ;; Globally disable grafts because they can trigger early builds.
51 (%graft? #f)
52
53 (define (bootstrap-binary name)
54 (let ((bin (search-bootstrap-binary name (%current-system))))
55 (and %store
56 (add-to-store %store name #t "sha256" bin))))
57
58 (define %bash
59 (bootstrap-binary "bash"))
60 (define %mkdir
61 (bootstrap-binary "mkdir"))
62
63 (define* (directory-contents dir #:optional (slurp get-bytevector-all))
64 "Return an alist representing the contents of DIR."
65 (define prefix-len (string-length dir))
66 (sort (file-system-fold (const #t) ; enter?
67 (lambda (path stat result) ; leaf
68 (alist-cons (string-drop path prefix-len)
69 (call-with-input-file path slurp)
70 result))
71 (lambda (path stat result) result) ; down
72 (lambda (path stat result) result) ; up
73 (lambda (path stat result) result) ; skip
74 (lambda (path stat errno result) result) ; error
75 '()
76 dir)
77 (lambda (e1 e2)
78 (string<? (car e1) (car e2)))))
79
80 ;; Avoid collisions with other tests.
81 (%http-server-port 10500)
82
83 \f
84 (test-begin "derivations")
85
86 (test-assert "parse & export"
87 (let* ((f (search-path %load-path "tests/test.drv"))
88 (b1 (call-with-input-file f get-bytevector-all))
89 (d1 (read-derivation (open-bytevector-input-port b1)
90 identity))
91 (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>)))
92 (d2 (read-derivation (open-bytevector-input-port b2)
93 identity)))
94 (and (equal? b1 b2)
95 (equal? d1 d2))))
96
97 (test-skip (if %store 0 12))
98
99 (test-assert "add-to-store, flat"
100 ;; Use 'readlink*' in case spec.scm is a symlink, as is the case when Guile
101 ;; was installed with Stow.
102 (let* ((file (readlink*
103 (search-path %load-path "language/tree-il/spec.scm")))
104 (drv (add-to-store %store "flat-test" #f "sha256" file)))
105 (and (eq? 'regular (stat:type (stat drv)))
106 (valid-path? %store drv)
107 (equal? (call-with-input-file file get-bytevector-all)
108 (call-with-input-file drv get-bytevector-all)))))
109
110 (test-assert "add-to-store, recursive"
111 (let* ((dir (dirname
112 (readlink* (search-path %load-path
113 "language/tree-il/spec.scm"))))
114 (drv (add-to-store %store "dir-tree-test" #t "sha256" dir)))
115 (and (eq? 'directory (stat:type (stat drv)))
116 (valid-path? %store drv)
117 (equal? (directory-contents dir)
118 (directory-contents drv)))))
119
120 (test-assert "derivation with no inputs"
121 (let* ((builder (add-text-to-store %store "my-builder.sh"
122 "echo hello, world\n"
123 '()))
124 (drv (derivation %store "foo"
125 %bash `("-e" ,builder)
126 #:env-vars '(("HOME" . "/homeless")))))
127 (and (store-path? (derivation-file-name drv))
128 (valid-path? %store (derivation-file-name drv)))))
129
130 (test-assert "build derivation with 1 source"
131 (let* ((builder (add-text-to-store %store "my-builder.sh"
132 "echo hello, world > \"$out\"\n"
133 '()))
134 (drv (derivation %store "foo"
135 %bash `(,builder)
136 #:env-vars '(("HOME" . "/homeless")
137 ("zzz" . "Z!")
138 ("AAA" . "A!"))
139 #:inputs `((,%bash) (,builder))))
140 (succeeded?
141 (build-derivations %store (list drv))))
142 (and succeeded?
143 (let ((path (derivation->output-path drv)))
144 (and (valid-path? %store path)
145 (string=? (call-with-input-file path read-line)
146 "hello, world"))))))
147
148 (test-assert "derivation with local file as input"
149 (let* ((builder (add-text-to-store
150 %store "my-builder.sh"
151 "(while read line ; do echo \"$line\" ; done) < $in > $out"
152 '()))
153 (input (search-path %load-path "ice-9/boot-9.scm"))
154 (input* (add-to-store %store (basename input)
155 #t "sha256" input))
156 (drv (derivation %store "derivation-with-input-file"
157 %bash `(,builder)
158
159 ;; Cheat to pass the actual file name to the
160 ;; builder.
161 #:env-vars `(("in" . ,input*))
162
163 #:inputs `((,%bash)
164 (,builder)
165 (,input))))) ; ← local file name
166 (and (build-derivations %store (list drv))
167 ;; Note: we can't compare the files because the above trick alters
168 ;; the contents.
169 (valid-path? %store (derivation->output-path drv)))))
170
171 (test-assert "derivation fails but keep going"
172 ;; In keep-going mode, 'build-derivations' should fail because of D1, but it
173 ;; must return only after D2 has succeeded.
174 (with-store store
175 (let* ((d1 (derivation %store "fails"
176 %bash `("-c" "false")
177 #:inputs `((,%bash))))
178 (d2 (build-expression->derivation %store "sleep-then-succeed"
179 `(begin
180 ,(random-text)
181 ;; XXX: Hopefully that's long
182 ;; enough that D1 has already
183 ;; failed.
184 (sleep 2)
185 (mkdir %output)))))
186 (set-build-options %store
187 #:use-substitutes? #f
188 #:keep-going? #t)
189 (guard (c ((store-protocol-error? c)
190 (and (= 100 (store-protocol-error-status c))
191 (string-contains (store-protocol-error-message c)
192 (derivation-file-name d1))
193 (not (valid-path? %store (derivation->output-path d1)))
194 (valid-path? %store (derivation->output-path d2)))))
195 (build-derivations %store (list d1 d2))
196 #f))))
197
198 (test-assert "identical files are deduplicated"
199 (let* ((build1 (add-text-to-store %store "one.sh"
200 "echo hello, world > \"$out\"\n"
201 '()))
202 (build2 (add-text-to-store %store "two.sh"
203 "# Hey!\necho hello, world > \"$out\"\n"
204 '()))
205 (drv1 (derivation %store "foo"
206 %bash `(,build1)
207 #:inputs `((,%bash) (,build1))))
208 (drv2 (derivation %store "bar"
209 %bash `(,build2)
210 #:inputs `((,%bash) (,build2)))))
211 (and (build-derivations %store (list drv1 drv2))
212 (let ((file1 (derivation->output-path drv1))
213 (file2 (derivation->output-path drv2)))
214 (and (valid-path? %store file1) (valid-path? %store file2)
215 (string=? (call-with-input-file file1 get-string-all)
216 "hello, world\n")
217 (= (stat:ino (lstat file1))
218 (stat:ino (lstat file2))))))))
219
220 (test-equal "built-in-builders"
221 '("download")
222 (built-in-builders %store))
223
224 (test-assert "unknown built-in builder"
225 (let ((drv (derivation %store "ohoh" "builtin:does-not-exist" '())))
226 (guard (c ((store-protocol-error? c)
227 (string-contains (store-protocol-error-message c) "failed")))
228 (build-derivations %store (list drv))
229 #f)))
230
231 (unless (http-server-can-listen?)
232 (test-skip 1))
233 (test-assert "'download' built-in builder"
234 (let ((text (random-text)))
235 (with-http-server 200 text
236 (let* ((drv (derivation %store "world"
237 "builtin:download" '()
238 #:env-vars `(("url"
239 . ,(object->string (%local-url))))
240 #:hash-algo 'sha256
241 #:hash (sha256 (string->utf8 text)))))
242 (and (build-derivations %store (list drv))
243 (string=? (call-with-input-file (derivation->output-path drv)
244 get-string-all)
245 text))))))
246
247 (unless (http-server-can-listen?)
248 (test-skip 1))
249 (test-assert "'download' built-in builder, invalid hash"
250 (with-http-server 200 "hello, world!"
251 (let* ((drv (derivation %store "world"
252 "builtin:download" '()
253 #:env-vars `(("url"
254 . ,(object->string (%local-url))))
255 #:hash-algo 'sha256
256 #:hash (sha256 (random-bytevector 100))))) ;wrong
257 (guard (c ((store-protocol-error? c)
258 (string-contains (store-protocol-error-message c) "failed")))
259 (build-derivations %store (list drv))
260 #f))))
261
262 (unless (http-server-can-listen?)
263 (test-skip 1))
264 (test-assert "'download' built-in builder, not found"
265 (with-http-server 404 "not found"
266 (let* ((drv (derivation %store "will-never-be-found"
267 "builtin:download" '()
268 #:env-vars `(("url"
269 . ,(object->string (%local-url))))
270 #:hash-algo 'sha256
271 #:hash (sha256 (random-bytevector 100)))))
272 (guard (c ((store-protocol-error? c)
273 (string-contains (store-protocol-error-message (pk c)) "failed")))
274 (build-derivations %store (list drv))
275 #f))))
276
277 (test-assert "'download' built-in builder, not fixed-output"
278 (let* ((source (add-text-to-store %store "hello" "hi!"))
279 (url (string-append "file://" source))
280 (drv (derivation %store "world"
281 "builtin:download" '()
282 #:env-vars `(("url" . ,(object->string url))))))
283 (guard (c ((store-protocol-error? c)
284 (string-contains (store-protocol-error-message c) "failed")))
285 (build-derivations %store (list drv))
286 #f)))
287
288 (unless (http-server-can-listen?)
289 (test-skip 1))
290 (test-assert "'download' built-in builder, check mode"
291 ;; Make sure rebuilding the 'builtin:download' derivation in check mode
292 ;; works. See <http://bugs.gnu.org/25089>.
293 (let* ((text (random-text))
294 (drv (derivation %store "world"
295 "builtin:download" '()
296 #:env-vars `(("url"
297 . ,(object->string (%local-url))))
298 #:hash-algo 'sha256
299 #:hash (sha256 (string->utf8 text)))))
300 (and (with-http-server 200 text
301 (build-derivations %store (list drv)))
302 (with-http-server 200 text
303 (build-derivations %store (list drv)
304 (build-mode check)))
305 (string=? (call-with-input-file (derivation->output-path drv)
306 get-string-all)
307 text))))
308
309 (test-equal "derivation-name"
310 "foo-0.0"
311 (let ((drv (derivation %store "foo-0.0" %bash '())))
312 (derivation-name drv)))
313
314 (test-equal "derivation-output-names"
315 '(("out") ("bar" "chbouib"))
316 (let ((drv1 (derivation %store "foo-0.0" %bash '()))
317 (drv2 (derivation %store "foo-0.0" %bash '()
318 #:outputs '("bar" "chbouib"))))
319 (list (derivation-output-names drv1)
320 (derivation-output-names drv2))))
321
322 (test-assert "offloadable-derivation?"
323 (and (offloadable-derivation? (derivation %store "foo" %bash '()))
324 (offloadable-derivation? ;see <http://bugs.gnu.org/18747>
325 (derivation %store "foo" %bash '()
326 #:substitutable? #f))
327 (not (offloadable-derivation?
328 (derivation %store "foo" %bash '()
329 #:local-build? #t)))))
330
331 (test-assert "substitutable-derivation?"
332 (and (substitutable-derivation? (derivation %store "foo" %bash '()))
333 (substitutable-derivation? ;see <http://bugs.gnu.org/18747>
334 (derivation %store "foo" %bash '()
335 #:local-build? #t))
336 (not (substitutable-derivation?
337 (derivation %store "foo" %bash '()
338 #:substitutable? #f)))))
339
340 (test-assert "fixed-output-derivation?"
341 (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
342 "echo -n hello > $out" '()))
343 (hash (sha256 (string->utf8 "hello")))
344 (drv (derivation %store "fixed"
345 %bash `(,builder)
346 #:inputs `((,builder))
347 #:hash hash #:hash-algo 'sha256)))
348 (fixed-output-derivation? drv)))
349
350 (test-assert "fixed-output derivation"
351 (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
352 "echo -n hello > $out" '()))
353 (hash (sha256 (string->utf8 "hello")))
354 (drv (derivation %store "fixed"
355 %bash `(,builder)
356 #:inputs `((,builder)) ; optional
357 #:hash hash #:hash-algo 'sha256))
358 (succeeded? (build-derivations %store (list drv))))
359 (and succeeded?
360 (let ((p (derivation->output-path drv)))
361 (and (equal? (string->utf8 "hello")
362 (call-with-input-file p get-bytevector-all))
363 (bytevector? (query-path-hash %store p)))))))
364
365 (test-assert "fixed-output derivation: output paths are equal"
366 (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh"
367 "echo -n hello > $out" '()))
368 (builder2 (add-text-to-store %store "fixed-builder2.sh"
369 "echo hey; echo -n hello > $out" '()))
370 (hash (sha256 (string->utf8 "hello")))
371 (drv1 (derivation %store "fixed"
372 %bash `(,builder1)
373 #:hash hash #:hash-algo 'sha256))
374 (drv2 (derivation %store "fixed"
375 %bash `(,builder2)
376 #:hash hash #:hash-algo 'sha256))
377 (succeeded? (build-derivations %store (list drv1 drv2))))
378 (and succeeded?
379 (equal? (derivation->output-path drv1)
380 (derivation->output-path drv2)))))
381
382 (test-assert "fixed-output derivation, recursive"
383 (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
384 "echo -n hello > $out" '()))
385 (hash (sha256 (string->utf8 "hello")))
386 (drv (derivation %store "fixed-rec"
387 %bash `(,builder)
388 #:inputs `((,builder))
389 #:hash (base32 "0sg9f58l1jj88w6pdrfdpj5x9b1zrwszk84j81zvby36q9whhhqa")
390 #:hash-algo 'sha256
391 #:recursive? #t))
392 (succeeded? (build-derivations %store (list drv))))
393 (and succeeded?
394 (let ((p (derivation->output-path drv)))
395 (and (equal? (string->utf8 "hello")
396 (call-with-input-file p get-bytevector-all))
397 (bytevector? (query-path-hash %store p)))))))
398
399 (test-assert "derivation with a fixed-output input"
400 ;; A derivation D using a fixed-output derivation F doesn't has the same
401 ;; output path when passed F or F', as long as F and F' have the same output
402 ;; path.
403 (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh"
404 "echo -n hello > $out" '()))
405 (builder2 (add-text-to-store %store "fixed-builder2.sh"
406 "echo hey; echo -n hello > $out" '()))
407 (hash (sha256 (string->utf8 "hello")))
408 (fixed1 (derivation %store "fixed"
409 %bash `(,builder1)
410 #:hash hash #:hash-algo 'sha256))
411 (fixed2 (derivation %store "fixed"
412 %bash `(,builder2)
413 #:hash hash #:hash-algo 'sha256))
414 (fixed-out (derivation->output-path fixed1))
415 (builder3 (add-text-to-store
416 %store "final-builder.sh"
417 ;; Use Bash hackery to avoid Coreutils.
418 "echo $in ; (read -u 3 c; echo $c) 3< $in > $out" '()))
419 (final1 (derivation %store "final"
420 %bash `(,builder3)
421 #:env-vars `(("in" . ,fixed-out))
422 #:inputs `((,%bash) (,builder3) (,fixed1))))
423 (final2 (derivation %store "final"
424 %bash `(,builder3)
425 #:env-vars `(("in" . ,fixed-out))
426 #:inputs `((,%bash) (,builder3) (,fixed2))))
427 (succeeded? (build-derivations %store
428 (list final1 final2))))
429 (and succeeded?
430 (equal? (derivation->output-path final1)
431 (derivation->output-path final2)))))
432
433 (test-assert "multiple-output derivation"
434 (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
435 "echo one > $out ; echo two > $second"
436 '()))
437 (drv (derivation %store "fixed"
438 %bash `(,builder)
439 #:env-vars '(("HOME" . "/homeless")
440 ("zzz" . "Z!")
441 ("AAA" . "A!"))
442 #:inputs `((,%bash) (,builder))
443 #:outputs '("out" "second")))
444 (succeeded? (build-derivations %store (list drv))))
445 (and succeeded?
446 (let ((one (derivation->output-path drv "out"))
447 (two (derivation->output-path drv "second")))
448 (and (lset= equal?
449 (derivation->output-paths drv)
450 `(("out" . ,one) ("second" . ,two)))
451 (eq? 'one (call-with-input-file one read))
452 (eq? 'two (call-with-input-file two read)))))))
453
454 (test-assert "multiple-output derivation, non-alphabetic order"
455 ;; Here, the outputs are not listed in alphabetic order. Yet, the store
456 ;; path computation must reorder them first.
457 (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
458 "echo one > $out ; echo two > $AAA"
459 '()))
460 (drv (derivation %store "fixed"
461 %bash `(,builder)
462 #:inputs `((,%bash) (,builder))
463 #:outputs '("out" "AAA")))
464 (succeeded? (build-derivations %store (list drv))))
465 (and succeeded?
466 (let ((one (derivation->output-path drv "out"))
467 (two (derivation->output-path drv "AAA")))
468 (and (eq? 'one (call-with-input-file one read))
469 (eq? 'two (call-with-input-file two read)))))))
470
471 (test-assert "read-derivation vs. derivation"
472 ;; Make sure 'derivation' and 'read-derivation' return objects that are
473 ;; identical.
474 (let* ((sources (unfold (cut >= <> 10)
475 (lambda (n)
476 (add-text-to-store %store
477 (format #f "input~a" n)
478 (random-text)))
479 1+
480 0))
481 (inputs (map (lambda (file)
482 (derivation %store "derivation-input"
483 %bash '()
484 #:inputs `((,%bash) (,file))))
485 sources))
486 (builder (add-text-to-store %store "builder.sh"
487 "echo one > $one ; echo two > $two"
488 '()))
489 (drv (derivation %store "derivation"
490 %bash `(,builder)
491 #:inputs `((,%bash) (,builder)
492 ,@(map list (append sources inputs)))
493 #:outputs '("two" "one")))
494 (drv* (call-with-input-file (derivation-file-name drv)
495 read-derivation)))
496 (equal? drv* drv)))
497
498 (test-assert "multiple-output derivation, derivation-path->output-path"
499 (let* ((builder (add-text-to-store %store "builder.sh"
500 "echo one > $out ; echo two > $second"
501 '()))
502 (drv (derivation %store "multiple"
503 %bash `(,builder)
504 #:outputs '("out" "second")))
505 (drv-file (derivation-file-name drv))
506 (one (derivation->output-path drv "out"))
507 (two (derivation->output-path drv "second"))
508 (first (derivation-path->output-path drv-file "out"))
509 (second (derivation-path->output-path drv-file "second")))
510 (and (not (string=? one two))
511 (string-suffix? "-second" two)
512 (string=? first one)
513 (string=? second two))))
514
515 (test-assert "user of multiple-output derivation"
516 ;; Check whether specifying several inputs coming from the same
517 ;; multiple-output derivation works.
518 (let* ((builder1 (add-text-to-store %store "my-mo-builder.sh"
519 "echo one > $out ; echo two > $two"
520 '()))
521 (mdrv (derivation %store "multiple-output"
522 %bash `(,builder1)
523 #:inputs `((,%bash) (,builder1))
524 #:outputs '("out" "two")))
525 (builder2 (add-text-to-store %store "my-mo-user-builder.sh"
526 "read x < $one;
527 read y < $two;
528 echo \"($x $y)\" > $out"
529 '()))
530 (udrv (derivation %store "multiple-output-user"
531 %bash `(,builder2)
532 #:env-vars `(("one"
533 . ,(derivation->output-path
534 mdrv "out"))
535 ("two"
536 . ,(derivation->output-path
537 mdrv "two")))
538 #:inputs `((,%bash)
539 (,builder2)
540 ;; two occurrences of MDRV:
541 (,mdrv)
542 (,mdrv "two")))))
543 (and (build-derivations %store (list (pk 'udrv udrv)))
544 (let ((p (derivation->output-path udrv)))
545 (and (valid-path? %store p)
546 (equal? '(one two) (call-with-input-file p read)))))))
547
548 (test-assert "derivation with #:references-graphs"
549 (let* ((input1 (add-text-to-store %store "foo" "hello"
550 (list %bash)))
551 (input2 (add-text-to-store %store "bar"
552 (number->string (random 7777))
553 (list input1)))
554 (builder (add-text-to-store %store "build-graph"
555 (format #f "
556 ~a $out
557 (while read l ; do echo $l ; done) < bash > $out/bash
558 (while read l ; do echo $l ; done) < input1 > $out/input1
559 (while read l ; do echo $l ; done) < input2 > $out/input2"
560 %mkdir)
561 (list %mkdir)))
562 (drv (derivation %store "closure-graphs"
563 %bash `(,builder)
564 #:references-graphs
565 `(("bash" . ,%bash)
566 ("input1" . ,input1)
567 ("input2" . ,input2))
568 #:inputs `((,%bash) (,builder))))
569 (out (derivation->output-path drv)))
570 (define (deps path . deps)
571 (let ((count (length deps)))
572 (string-append path "\n\n" (number->string count) "\n"
573 (string-join (sort deps string<?) "\n")
574 (if (zero? count) "" "\n"))))
575
576 (and (build-derivations %store (list drv))
577 (equal? (directory-contents out get-string-all)
578 `(("/bash" . ,(string-append %bash "\n\n0\n"))
579 ("/input1" . ,(if (string>? input1 %bash)
580 (string-append (deps %bash)
581 (deps input1 %bash))
582 (string-append (deps input1 %bash)
583 (deps %bash))))
584 ("/input2" . ,(string-concatenate
585 (map cdr
586 (sort
587 (map (lambda (p d)
588 (cons p (apply deps p d)))
589 (list %bash input1 input2)
590 (list '() (list %bash) (list input1)))
591 (lambda (x y)
592 (match x
593 ((p1 . _)
594 (match y
595 ((p2 . _)
596 (string<? p1 p2)))))))))))))))
597
598 (test-assert "derivation #:allowed-references, ok"
599 (let ((drv (derivation %store "allowed" %bash
600 '("-c" "echo hello > $out")
601 #:inputs `((,%bash))
602 #:allowed-references '())))
603 (build-derivations %store (list drv))))
604
605 (test-assert "derivation #:allowed-references, not allowed"
606 (let* ((txt (add-text-to-store %store "foo" "Hello, world."))
607 (drv (derivation %store "disallowed" %bash
608 `("-c" ,(string-append "echo " txt "> $out"))
609 #:inputs `((,%bash) (,txt))
610 #:allowed-references '())))
611 (guard (c ((store-protocol-error? c)
612 ;; There's no specific error message to check for.
613 #t))
614 (build-derivations %store (list drv))
615 #f)))
616
617 (test-assert "derivation #:allowed-references, self allowed"
618 (let ((drv (derivation %store "allowed" %bash
619 '("-c" "echo $out > $out")
620 #:inputs `((,%bash))
621 #:allowed-references '("out"))))
622 (build-derivations %store (list drv))))
623
624 (test-assert "derivation #:allowed-references, self not allowed"
625 (let ((drv (derivation %store "disallowed" %bash
626 `("-c" ,"echo $out > $out")
627 #:inputs `((,%bash))
628 #:allowed-references '())))
629 (guard (c ((store-protocol-error? c)
630 ;; There's no specific error message to check for.
631 #t))
632 (build-derivations %store (list drv))
633 #f)))
634
635 (test-assert "derivation #:disallowed-references, ok"
636 (let ((drv (derivation %store "disallowed" %bash
637 '("-c" "echo hello > $out")
638 #:inputs `((,%bash))
639 #:disallowed-references '("out"))))
640 (build-derivations %store (list drv))))
641
642 (test-assert "derivation #:disallowed-references, not ok"
643 (let* ((txt (add-text-to-store %store "foo" "Hello, world."))
644 (drv (derivation %store "disdisallowed" %bash
645 `("-c" ,(string-append "echo " txt "> $out"))
646 #:inputs `((,%bash) (,txt))
647 #:disallowed-references (list txt))))
648 (guard (c ((store-protocol-error? c)
649 ;; There's no specific error message to check for.
650 #t))
651 (build-derivations %store (list drv))
652 #f)))
653
654 ;; Here we should get the value of $GUIX_STATE_DIRECTORY that the daemon sees,
655 ;; which is a unique value for each test process; this value is the same as
656 ;; the one we see in the process executing this file since it is set by
657 ;; 'test-env'.
658 (test-equal "derivation #:leaked-env-vars"
659 (getenv "GUIX_STATE_DIRECTORY")
660 (let* ((value (getenv "GUIX_STATE_DIRECTORY"))
661 (drv (derivation %store "leaked-env-vars" %bash
662 '("-c" "echo -n $GUIX_STATE_DIRECTORY > $out")
663 #:hash (sha256 (string->utf8 value))
664 #:hash-algo 'sha256
665 #:inputs `((,%bash))
666 #:leaked-env-vars '("GUIX_STATE_DIRECTORY"))))
667 (and (build-derivations %store (list drv))
668 (call-with-input-file (derivation->output-path drv)
669 get-string-all))))
670
671 \f
672 (define %coreutils
673 (false-if-exception
674 (and (network-reachable?)
675 (package-derivation %store %bootstrap-coreutils&co))))
676
677 (test-skip (if %coreutils 0 1))
678
679 (test-assert "build derivation with coreutils"
680 (let* ((builder
681 (add-text-to-store %store "build-with-coreutils.sh"
682 "echo $PATH ; mkdir --version ; mkdir $out ; touch $out/good"
683 '()))
684 (drv
685 (derivation %store "foo"
686 %bash `(,builder)
687 #:env-vars `(("PATH" .
688 ,(string-append
689 (derivation->output-path %coreutils)
690 "/bin")))
691 #:inputs `((,builder)
692 (,%coreutils))))
693 (succeeded?
694 (build-derivations %store (list drv))))
695 (and succeeded?
696 (let ((p (derivation->output-path drv)))
697 (and (valid-path? %store p)
698 (file-exists? (string-append p "/good")))))))
699
700 (test-skip (if (%guile-for-build) 0 8))
701
702 (test-equal "build-expression->derivation and invalid module name"
703 '(file-search-error "guix/module/that/does/not/exist.scm")
704 (guard (c ((file-search-error? c)
705 (list 'file-search-error
706 (file-search-error-file-name c))))
707 (build-expression->derivation %store "foo" #t
708 #:modules '((guix module that
709 does not exist)))))
710
711 (test-equal "build-expression->derivation and builder encoding"
712 '("UTF-8" #t)
713 (let* ((exp '(λ (α) (+ α 1)))
714 (drv (build-expression->derivation %store "foo" exp)))
715 (match (derivation-builder-arguments drv)
716 ((... builder)
717 (with-fluids ((%default-port-encoding "UTF-8"))
718 (call-with-input-file builder
719 (lambda (port)
720 (list (port-encoding port)
721 (->bool
722 (string-contains (get-string-all port)
723 "(λ (α) (+ α 1))"))))))))))
724
725 (test-assert "build-expression->derivation and derivation-prerequisites"
726 (let ((drv (build-expression->derivation %store "fail" #f)))
727 (any (match-lambda
728 (($ <derivation-input> (= derivation-file-name path))
729 (string=? path (derivation-file-name (%guile-for-build)))))
730 (derivation-prerequisites drv))))
731
732 (test-assert "derivation-prerequisites and valid-derivation-input?"
733 (let* ((a (build-expression->derivation %store "a" '(mkdir %output)))
734 (b (build-expression->derivation %store "b" `(list ,(random-text))))
735 (c (build-expression->derivation %store "c" `(mkdir %output)
736 #:inputs `(("a" ,a) ("b" ,b)))))
737 ;; Make sure both A and %BOOTSTRAP-GUILE are built (the latter could have
738 ;; be removed by tests/guix-gc.sh.)
739 (build-derivations %store
740 (list a (package-derivation %store %bootstrap-guile)))
741
742 (match (derivation-prerequisites c
743 (cut valid-derivation-input? %store
744 <>))
745 ((($ <derivation-input> (= derivation-file-name file) ("out")))
746 (string=? file (derivation-file-name b)))
747 (x
748 (pk 'fail x #f)))))
749
750 (test-assert "build-expression->derivation without inputs"
751 (let* ((builder '(begin
752 (mkdir %output)
753 (call-with-output-file (string-append %output "/test")
754 (lambda (p)
755 (display '(hello guix) p)))))
756 (drv (build-expression->derivation %store "goo" builder))
757 (succeeded? (build-derivations %store (list drv))))
758 (and succeeded?
759 (let ((p (derivation->output-path drv)))
760 (equal? '(hello guix)
761 (call-with-input-file (string-append p "/test") read))))))
762
763 (test-assert "build-expression->derivation and max-silent-time"
764 (let* ((store (let ((s (open-connection)))
765 (set-build-options s #:max-silent-time 1)
766 s))
767 (builder '(begin (sleep 100) (mkdir %output) #t))
768 (drv (build-expression->derivation store "silent" builder))
769 (out-path (derivation->output-path drv)))
770 (guard (c ((store-protocol-error? c)
771 (and (string-contains (store-protocol-error-message c)
772 "failed")
773 (not (valid-path? store out-path)))))
774 (build-derivations store (list drv))
775 #f)))
776
777 (test-assert "build-expression->derivation and timeout"
778 (let* ((store (let ((s (open-connection)))
779 (set-build-options s #:timeout 1)
780 s))
781 (builder '(begin (sleep 100) (mkdir %output) #t))
782 (drv (build-expression->derivation store "slow" builder))
783 (out-path (derivation->output-path drv)))
784 (guard (c ((store-protocol-error? c)
785 (and (string-contains (store-protocol-error-message c)
786 "failed")
787 (not (valid-path? store out-path)))))
788 (build-derivations store (list drv))
789 #f)))
790
791 (test-assert "build-derivations with specific output"
792 (with-store store
793 (let* ((content (random-text)) ;contents of the output
794 (drv (build-expression->derivation
795 store "substitute-me"
796 `(begin ,content (exit 1)) ;would fail
797 #:outputs '("out" "one" "two")
798 #:guile-for-build
799 (package-derivation store %bootstrap-guile)))
800 (out (derivation->output-path drv)))
801 (with-derivation-substitute drv content
802 (set-build-options store #:use-substitutes? #t
803 #:substitute-urls (%test-substitute-urls))
804 (and (has-substitutes? store out)
805
806 ;; Ask for nothing but the "out" output of DRV.
807 (build-derivations store `((,drv . "out")))
808
809 ;; Synonymous:
810 (build-derivations store (list (derivation-input drv '("out"))))
811
812 (valid-path? store out)
813 (equal? (pk 'x content)
814 (pk 'y (call-with-input-file out get-string-all))))))))
815
816 (test-assert "build-expression->derivation and derivation-build-plan"
817 (let ((drv (build-expression->derivation %store "fail" #f)))
818 ;; The only direct dependency is (%guile-for-build) and it's already
819 ;; built.
820 (null? (derivation-build-plan %store (derivation-inputs drv)))))
821
822 (test-assert "derivation-build-plan when outputs already present"
823 (let* ((builder `(begin ,(random-text) (mkdir %output) #t))
824 (input-drv (build-expression->derivation %store "input" builder))
825 (input-path (derivation->output-path input-drv))
826 (drv (build-expression->derivation %store "something" builder
827 #:inputs
828 `(("i" ,input-drv))))
829 (output (derivation->output-path drv)))
830 ;; Assume these things are not already built.
831 (when (or (valid-path? %store input-path)
832 (valid-path? %store output))
833 (error "things already built" input-drv))
834
835 (and (lset= equal?
836 (map derivation-file-name
837 (derivation-build-plan %store
838 (list (derivation-input drv))))
839 (list (derivation-file-name input-drv)
840 (derivation-file-name drv)))
841
842 ;; Build DRV and delete its input.
843 (build-derivations %store (list drv))
844 (delete-paths %store (list input-path))
845 (not (valid-path? %store input-path))
846
847 ;; Now INPUT-PATH is missing, yet it shouldn't be listed as a
848 ;; prerequisite to build because DRV itself is already built.
849 (null? (derivation-build-plan %store
850 (list (derivation-input drv)))))))
851
852 (test-assert "derivation-build-plan and substitutes"
853 (let* ((store (open-connection))
854 (drv (build-expression->derivation store "prereq-subst"
855 (random 1000)))
856 (output (derivation->output-path drv)))
857
858 ;; Make sure substitutes are usable.
859 (set-build-options store #:use-substitutes? #t
860 #:substitute-urls (%test-substitute-urls))
861
862 (with-derivation-narinfo drv
863 (let-values (((build download)
864 (derivation-build-plan store
865 (list (derivation-input drv))))
866 ((build* download*)
867 (derivation-build-plan store
868 (list (derivation-input drv))
869 #:substitutable-info
870 (const #f))))
871 (and (null? build)
872 (equal? (map substitutable-path download) (list output))
873 (null? download*)
874 (equal? (list drv) build*))))))
875
876 (test-assert "derivation-build-plan and substitutes, non-substitutable build"
877 (let* ((store (open-connection))
878 (drv (build-expression->derivation store "prereq-no-subst"
879 (random 1000)
880 #:substitutable? #f))
881 (output (derivation->output-path drv)))
882
883 ;; Make sure substitutes are usable.
884 (set-build-options store #:use-substitutes? #t
885 #:substitute-urls (%test-substitute-urls))
886
887 (with-derivation-narinfo drv
888 (let-values (((build download)
889 (derivation-build-plan store
890 (list (derivation-input drv)))))
891 ;; Despite being available as a substitute, DRV will be built locally
892 ;; due to #:substitutable? #f.
893 (and (null? download)
894 (match build
895 (((= derivation-file-name build))
896 (string=? build (derivation-file-name drv)))))))))
897
898 (test-assert "derivation-build-plan and substitutes, local build"
899 (with-store store
900 (let* ((drv (build-expression->derivation store "prereq-subst-local"
901 (random 1000)
902 #:local-build? #t))
903 (output (derivation->output-path drv)))
904
905 ;; Make sure substitutes are usable.
906 (set-build-options store #:use-substitutes? #t
907 #:substitute-urls (%test-substitute-urls))
908
909 (with-derivation-narinfo drv
910 (let-values (((build download)
911 (derivation-build-plan store
912 (list (derivation-input drv)))))
913 ;; #:local-build? is *not* synonymous with #:substitutable?, so we
914 ;; must be able to substitute DRV's output.
915 ;; See <http://bugs.gnu.org/18747>.
916 (and (null? build)
917 (match download
918 (((= substitutable-path item))
919 (string=? item (derivation->output-path drv))))))))))
920
921 (test-assert "derivation-build-plan in 'check' mode"
922 (with-store store
923 (let* ((dep (build-expression->derivation store "dep"
924 `(begin ,(random-text)
925 (mkdir %output))))
926 (drv (build-expression->derivation store "to-check"
927 '(mkdir %output)
928 #:inputs `(("dep" ,dep)))))
929 (build-derivations store (list drv))
930 (delete-paths store (list (derivation->output-path dep)))
931
932 ;; In 'check' mode, DEP must be rebuilt.
933 (and (null? (derivation-build-plan store
934 (list (derivation-input drv))))
935 (lset= equal?
936 (derivation-build-plan store
937 (list (derivation-input drv))
938 #:mode (build-mode check))
939 (list drv dep))))))
940
941 (test-assert "substitution-oracle and #:substitute? #f"
942 (with-store store
943 (let* ((dep (build-expression->derivation store "dep"
944 `(begin ,(random-text)
945 (mkdir %output))))
946 (drv (build-expression->derivation store "not-subst"
947 `(begin ,(random-text)
948 (mkdir %output))
949 #:substitutable? #f
950 #:inputs `(("dep" ,dep))))
951 (query #f))
952 (define (record-substitutable-path-query store paths)
953 (when query
954 (error "already called!" query))
955 (set! query paths)
956 '())
957
958 (mock ((guix store) substitutable-path-info
959 record-substitutable-path-query)
960
961 (let ((pred (substitution-oracle store (list drv))))
962 (pred (derivation->output-path drv))))
963
964 ;; Make sure the oracle didn't try to get substitute info for DRV since
965 ;; DRV is mark as non-substitutable. Assume that GUILE-FOR-BUILD is
966 ;; already in store and thus not part of QUERY.
967 (equal? (pk 'query query)
968 (list (derivation->output-path dep))))))
969
970 (test-assert "build-expression->derivation with expression returning #f"
971 (let* ((builder '(begin
972 (mkdir %output)
973 #f)) ; fail!
974 (drv (build-expression->derivation %store "fail" builder))
975 (out-path (derivation->output-path drv)))
976 (guard (c ((store-protocol-error? c)
977 ;; Note that the output path may exist at this point, but it
978 ;; is invalid.
979 (and (string-match "build .* failed"
980 (store-protocol-error-message c))
981 (not (valid-path? %store out-path)))))
982 (build-derivations %store (list drv))
983 #f)))
984
985 (test-assert "build-expression->derivation with two outputs"
986 (let* ((builder '(begin
987 (call-with-output-file (assoc-ref %outputs "out")
988 (lambda (p)
989 (display '(hello) p)))
990 (call-with-output-file (assoc-ref %outputs "second")
991 (lambda (p)
992 (display '(world) p)))))
993 (drv (build-expression->derivation %store "double" builder
994 #:outputs '("out"
995 "second")))
996 (succeeded? (build-derivations %store (list drv))))
997 (and succeeded?
998 (let ((one (derivation->output-path drv))
999 (two (derivation->output-path drv "second")))
1000 (and (equal? '(hello) (call-with-input-file one read))
1001 (equal? '(world) (call-with-input-file two read)))))))
1002
1003 (test-skip (if %coreutils 0 1))
1004 (test-assert "build-expression->derivation with one input"
1005 (let* ((builder '(call-with-output-file %output
1006 (lambda (p)
1007 (let ((cu (assoc-ref %build-inputs "cu")))
1008 (close 1)
1009 (dup2 (port->fdes p) 1)
1010 (execl (string-append cu "/bin/uname")
1011 "uname" "-a")))))
1012 (drv (build-expression->derivation %store "uname" builder
1013 #:inputs
1014 `(("cu" ,%coreutils))))
1015 (succeeded? (build-derivations %store (list drv))))
1016 (and succeeded?
1017 (let ((p (derivation->output-path drv)))
1018 (string-contains (call-with-input-file p read-line) "GNU")))))
1019
1020 (test-assert "build-expression->derivation with modules"
1021 (let* ((builder `(begin
1022 (use-modules (guix build utils))
1023 (let ((out (assoc-ref %outputs "out")))
1024 (mkdir-p (string-append out "/guile/guix/nix"))
1025 #t)))
1026 (drv (build-expression->derivation %store "test-with-modules"
1027 builder
1028 #:modules
1029 '((guix build utils)))))
1030 (and (build-derivations %store (list drv))
1031 (let* ((p (derivation->output-path drv))
1032 (s (stat (string-append p "/guile/guix/nix"))))
1033 (eq? (stat:type s) 'directory)))))
1034
1035 (test-assert "build-expression->derivation: same fixed-output path"
1036 (let* ((builder1 '(call-with-output-file %output
1037 (lambda (p)
1038 (write "hello" p))))
1039 (builder2 '(call-with-output-file (pk 'difference-here! %output)
1040 (lambda (p)
1041 (write "hello" p))))
1042 (hash (sha256 (string->utf8 "hello")))
1043 (input1 (build-expression->derivation %store "fixed" builder1
1044 #:hash hash
1045 #:hash-algo 'sha256))
1046 (input2 (build-expression->derivation %store "fixed" builder2
1047 #:hash hash
1048 #:hash-algo 'sha256))
1049 (succeeded? (build-derivations %store (list input1 input2))))
1050 (and succeeded?
1051 (not (string=? (derivation-file-name input1)
1052 (derivation-file-name input2)))
1053 (string=? (derivation->output-path input1)
1054 (derivation->output-path input2)))))
1055
1056 (test-assert "build-expression->derivation with a fixed-output input"
1057 (let* ((builder1 '(call-with-output-file %output
1058 (lambda (p)
1059 (write "hello" p))))
1060 (builder2 '(call-with-output-file (pk 'difference-here! %output)
1061 (lambda (p)
1062 (write "hello" p))))
1063 (hash (sha256 (string->utf8 "hello")))
1064 (input1 (build-expression->derivation %store "fixed" builder1
1065 #:hash hash
1066 #:hash-algo 'sha256))
1067 (input2 (build-expression->derivation %store "fixed" builder2
1068 #:hash hash
1069 #:hash-algo 'sha256))
1070 (builder3 '(let ((input (assoc-ref %build-inputs "input")))
1071 (call-with-output-file %output
1072 (lambda (out)
1073 (format #f "My input is ~a.~%" input)))))
1074 (final1 (build-expression->derivation %store "final" builder3
1075 #:inputs
1076 `(("input" ,input1))))
1077 (final2 (build-expression->derivation %store "final" builder3
1078 #:inputs
1079 `(("input" ,input2)))))
1080 (and (string=? (derivation->output-path final1)
1081 (derivation->output-path final2))
1082 (string=? (derivation->output-path final1)
1083 (derivation-path->output-path
1084 (derivation-file-name final1)))
1085 (build-derivations %store (list final1 final2)))))
1086
1087 (test-assert "build-expression->derivation produces recursive fixed-output"
1088 (let* ((builder '(begin
1089 (use-modules (srfi srfi-26))
1090 (mkdir %output)
1091 (chdir %output)
1092 (call-with-output-file "exe"
1093 (cut display "executable" <>))
1094 (chmod "exe" #o777)
1095 (symlink "exe" "symlink")
1096 (mkdir "subdir")))
1097 (drv (build-expression->derivation %store "fixed-rec" builder
1098 #:hash-algo 'sha256
1099 #:hash (base32
1100 "10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p")
1101 #:recursive? #t)))
1102 (and (build-derivations %store (list drv))
1103 (let* ((dir (derivation->output-path drv))
1104 (exe (string-append dir "/exe"))
1105 (link (string-append dir "/symlink"))
1106 (subdir (string-append dir "/subdir")))
1107 (and (executable-file? exe)
1108 (string=? "executable"
1109 (call-with-input-file exe get-string-all))
1110 (string=? "exe" (readlink link))
1111 (file-is-directory? subdir))))))
1112
1113 (test-assert "build-expression->derivation uses recursive fixed-output"
1114 (let* ((builder '(call-with-output-file %output
1115 (lambda (port)
1116 (display "hello" port))))
1117 (fixed (build-expression->derivation %store "small-fixed-rec"
1118 builder
1119 #:hash-algo 'sha256
1120 #:hash (base32
1121 "0sg9f58l1jj88w6pdrfdpj5x9b1zrwszk84j81zvby36q9whhhqa")
1122 #:recursive? #t))
1123 (in (derivation->output-path fixed))
1124 (builder `(begin
1125 (mkdir %output)
1126 (chdir %output)
1127 (symlink ,in "symlink")))
1128 (drv (build-expression->derivation %store "fixed-rec-user"
1129 builder
1130 #:inputs `(("fixed" ,fixed)))))
1131 (and (build-derivations %store (list drv))
1132 (let ((out (derivation->output-path drv)))
1133 (string=? (readlink (string-append out "/symlink")) in)))))
1134
1135 (test-assert "build-expression->derivation with #:references-graphs"
1136 (let* ((input (add-text-to-store %store "foo" "hello"
1137 (list %bash %mkdir)))
1138 (builder '(copy-file "input" %output))
1139 (drv (build-expression->derivation %store "references-graphs"
1140 builder
1141 #:references-graphs
1142 `(("input" . ,input))))
1143 (out (derivation->output-path drv)))
1144 (define (deps path . deps)
1145 (let ((count (length deps)))
1146 (string-append path "\n\n" (number->string count) "\n"
1147 (string-join (sort deps string<?) "\n")
1148 (if (zero? count) "" "\n"))))
1149
1150 (and (build-derivations %store (list drv))
1151 (equal? (call-with-input-file out get-string-all)
1152 (string-concatenate
1153 (map cdr
1154 (sort (map (lambda (p d)
1155 (cons p (apply deps p d)))
1156 (list input %bash %mkdir)
1157 (list (list %bash %mkdir)
1158 '() '()))
1159 (lambda (x y)
1160 (match x
1161 ((p1 . _)
1162 (match y
1163 ((p2 . _)
1164 (string<? p1 p2)))))))))))))
1165
1166 (test-equal "derivation-properties"
1167 (list '() '((type . test)))
1168 (let ((drv1 (build-expression->derivation %store "bar"
1169 '(mkdir %output)))
1170 (drv2 (build-expression->derivation %store "foo"
1171 '(mkdir %output)
1172 #:properties '((type . test)))))
1173 (list (derivation-properties drv1)
1174 (derivation-properties drv2))))
1175
1176 (test-equal "map-derivation"
1177 "hello"
1178 (let* ((joke (package-derivation %store guile-1.8))
1179 (good (package-derivation %store %bootstrap-guile))
1180 (drv1 (build-expression->derivation %store "original-drv1"
1181 #f ; systematically fail
1182 #:guile-for-build joke))
1183 (drv2 (build-expression->derivation %store "original-drv2"
1184 '(call-with-output-file %output
1185 (lambda (p)
1186 (display "hello" p)))))
1187 (drv3 (build-expression->derivation %store "drv-to-remap"
1188 '(let ((in (assoc-ref
1189 %build-inputs "in")))
1190 (copy-file in %output))
1191 #:inputs `(("in" ,drv1))
1192 #:guile-for-build joke))
1193 (drv4 (map-derivation %store drv3 `((,drv1 . ,drv2)
1194 (,joke . ,good))))
1195 (out (derivation->output-path drv4)))
1196 (and (build-derivations %store (list (pk 'remapped drv4)))
1197 (call-with-input-file out get-string-all))))
1198
1199 (test-equal "map-derivation, sources"
1200 "hello"
1201 (let* ((script1 (add-text-to-store %store "fail.sh" "exit 1"))
1202 (script2 (add-text-to-store %store "hi.sh" "echo -n hello > $out"))
1203 (bash-full (package-derivation %store (@ (gnu packages bash) bash)))
1204 (drv1 (derivation %store "drv-to-remap"
1205
1206 ;; XXX: This wouldn't work in practice, but if
1207 ;; we append "/bin/bash" then we can't replace
1208 ;; it with the bootstrap bash, which is a
1209 ;; single file.
1210 (derivation->output-path bash-full)
1211
1212 `("-e" ,script1)
1213 #:inputs `((,bash-full) (,script1))))
1214 (drv2 (map-derivation %store drv1
1215 `((,bash-full . ,%bash)
1216 (,script1 . ,script2))))
1217 (out (derivation->output-path drv2)))
1218 (and (build-derivations %store (list (pk 'remapped* drv2)))
1219 (call-with-input-file out get-string-all))))
1220
1221 (test-end)
1222
1223 ;; Local Variables:
1224 ;; eval: (put 'with-http-server 'scheme-indent-function 2)
1225 ;; End: