diff --git a/core/src/nixpkgs.sld b/core/src/nixpkgs.sld index 2fd932c..3b22b88 100644 --- a/core/src/nixpkgs.sld +++ b/core/src/nixpkgs.sld @@ -112,6 +112,7 @@ (define processor (string-append "if [ -e \"$NIX_ATTRS_SH_FILE\" ]; then source \"$NIX_ATTRS_SH_FILE\"; fi export IN_NIX_SHELL=impure; export dontAddDisableDepTrack=1 + export NIX_OUTPATH_USED_AS_RANDOM_SEED=/nix/store/zilchzilchzilchzilch if [[ -n $stdenv ]]; then source $stdenv/setup fi @@ -123,10 +124,9 @@ str=\"${str//$'\\r'/\\\\r}\" printf '\"%s\"' \"$str\" } - out=" (make-placeholder "out") " - printf '(' > $out + printf '(' > $zilch_out __run() { - declare -p | while read __line; do + declare -p | grep -v zilch_out | while read __line; do if ! [[ $__line =~ ^declare\\ (-[^ ])\\ ([^=]*) ]]; then continue; fi local __varname=\"${BASH_REMATCH[2]}\" if [[ \"${BASH_REMATCH[1]}\" == -x ]]; then @@ -138,22 +138,38 @@ fi done } - __run >> $out - printf ')' >> $out\n")) + __run >> $zilch_out + printf ')' >> $zilch_out\n")) + (define output-names (map car (derivation-outputs drv))) (define new-env (list)) + + (define base-placeholder "zilchplaceholderdonotuseanywhere-") + (define name (derivation-name drv)) + (define placeholders + (map + (lambda (l) + (cons (car l) + (string-append "/nix/store/" (car l) (string-copy base-placeholder (string-length (car l))) name (if (string=? (car l) "out") "" (string-append "-" (car l)))))) + (derivation-outputs drv))) (for-each (lambda (kv) - (unless (member (car kv) '("out" "name" "builder" "system" "allowedReferences" "disallowedReferences" "allowedRequisites" "disallowedRequisites") string=?) (set! new-env (cons kv new-env)))) + (cond + ((member (car kv) '("name" "src" "builder" "system" "allowedReferences" "disallowedReferences" "allowedRequisites" "disallowedRequisites") string=?) + #f) + ((member (car kv) output-names string=?) + (set! new-env (cons (assoc (car kv) placeholders) new-env))) + (else + (set! new-env (cons kv new-env))))) (derivation-env drv)) (define is-ca-derivation (symbol? (derivation-output-hash (cdar (derivation-outputs drv))))) (define out-drv - ((if is-ca-derivation make-ca-derivation make-input-addressed-derivation) "zilch-env" + (make-ca-derivation "zilch-env" (derivation-system drv) (derivation-input-drvs drv) (derivation-input-src drv) (list (derivation-builder drv) "-c" processor) new-env - '("out"))) - (define environment (call-with-port (store-path-open (make-store-path out-drv "out" #f)) (lambda (p) (read p)))) - (make-zexp (lambda () (zexp-context-register-items (list (list out-drv "out")) '()) environment) (lambda (p) (fprintf p "" (derivation-path drv))))))) + '("zilch_out"))) + (define environment (call-with-port (store-path-open (make-store-path out-drv "zilch_out" #f)) (lambda (p) (read p)))) + (make-zexp (lambda () (zexp-context-register-items (list (list out-drv "zilch_out")) '()) environment) (lambda (p) (fprintf p "" (derivation-path drv)))))))