build: Pass $(NIX_INSTANTIATE) to the build and test environments.

* Makefile.am (.scm.go): Define $NIX_INSTANTIATE.
  (TESTS_ENVIRONMENT): Likewise, and define $NIX_HASH.
* guix/utils.scm (nixpkgs-derivation): Use $NIX_INSTANTIATE when
  defined.

* tests/utils.scm (%nix-hash): New variable.
  ("sha256 & bytevector->nix-base32-string"): Use it.
This commit is contained in:
Ludovic Courtès 2012-08-14 18:36:01 +02:00
parent ed795c0608
commit b86b00567c
3 changed files with 14 additions and 6 deletions

View File

@ -52,9 +52,11 @@ TESTS = \
tests/packages.scm
TESTS_ENVIRONMENT = \
NIX_HASH="$(NIX_HASH)"; \
NIX_INSTANTIATE="$(NIX_INSTANTIATE)"; \
NIXPKGS="$(NIXPKGS)"; \
GUILE_LOAD_COMPILED_PATH="$(top_builddir):$$GUILE_LOAD_COMPILED_PATH"; \
export NIXPKGS GUILE_LOAD_COMPILED_PATH;
export NIX_HASH NIX_INSTANTIATE NIXPKGS GUILE_LOAD_COMPILED_PATH;
LOG_COMPILER = \
$(GUILE) --no-auto-compile -L "$(top_srcdir)"
@ -70,6 +72,7 @@ CLEANFILES = $(GOBJECTS) *.log
.scm.go:
$(MKDIR_P) `dirname "$@"`
NIX_INSTANTIATE="$(NIX_INSTANTIATE)" \
NIXPKGS="$(NIXPKGS)" \
GUILE_AUTO_COMPILE=0 \
GUILE_LOAD_COMPILED_PATH="$(top_builddir):$$GUILE_LOAD_COMPILED_PATH" \

View File

@ -450,8 +450,9 @@ starting from the right of S."
(define (nixpkgs-derivation attribute)
"Return the derivation path of ATTRIBUTE in Nixpkgs."
(let* ((p (open-pipe* OPEN_READ "nix-instantiate" "-A"
attribute (%nixpkgs-directory)))
(let* ((p (open-pipe* OPEN_READ (or (getenv "NIX_INSTANTIATE")
"nix-instantiate")
"-A" attribute (%nixpkgs-directory)))
(l (read-line p))
(s (close-pipe p)))
(and (zero? (status:exit-val s))

View File

@ -29,6 +29,10 @@
#:use-module (ice-9 popen)
#:use-module (ice-9 match))
(define %nix-hash
(or (getenv "NIX_HASH")
"nix-hash"))
(test-begin "utils")
(test-assert "bytevector->base32-string"
@ -72,7 +76,7 @@
(map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))))
;; The following tests requires `nix-hash' in $PATH.
(test-skip (if (false-if-exception (system* "nix-hash" "--version"))
(test-skip (if (false-if-exception (system* %nix-hash "--version"))
0
1))
@ -80,8 +84,8 @@
(let ((file (search-path %load-path "tests/test.drv")))
(equal? (bytevector->nix-base32-string
(sha256 (call-with-input-file file get-bytevector-all)))
(let* ((c (format #f "nix-hash --type sha256 --base32 --flat \"~a\""
file))
(let* ((c (format #f "~a --type sha256 --base32 --flat \"~a\""
%nix-hash file))
(p (open-input-pipe c))
(l (read-line p)))
(close-pipe p)