1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-28 12:01:49 +02:00

Add support for fixed-output derivations.

* guix/derivations.scm (read-derivation)[outputs->alist]: For
  fixed-outputs, convert HASH with `base16-string->bytevector'.
  (write-derivation): Likewise, convert HASH-ALGO to a string and HASH
  to a base16 string.
  (derivation-hash): Expect HASH to be a bytevector, not a string;
  convert HASH with `bytevector->base16-string'.

* tests/derivations.scm ("fixed-output derivation"): New test.
This commit is contained in:
Ludovic Courtès
2012-06-09 18:49:19 +02:00
parent 6d800a80ea
commit 749c656755
2 changed files with 25 additions and 6 deletions
+15
View File
@@ -25,6 +25,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-64)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors)
#:use-module (ice-9 rdelim))
(define %store
@@ -68,6 +69,20 @@
(string=? (call-with-input-file path read-line)
"hello, world")))))
(test-assert "fixed-output derivation"
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo -n hello > $out" '()))
(hash (sha256 (string->utf8 "hello")))
(drv-path (derivation %store "fixed" "x86_64-linux"
"/bin/sh" `(,builder)
'() `((,builder))
#:hash hash #:hash-algo 'sha256))
(succeeded? (build-derivations %store (list drv-path))))
(and succeeded?
(let ((p (derivation-path->output-path drv-path)))
(equal? (string->utf8 "hello")
(call-with-input-file p get-bytevector-all))))))
(define %coreutils
(false-if-exception (nixpkgs-derivation "coreutils")))