diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index d6bb35c99a..a8becea2de 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -592,15 +592,16 @@ (define graft? (assoc-ref opts 'graft?)) (parameterize ((%graft? graft?)) (append-map (match-lambda ((? package? p) - (match src - (#f - (list (package->derivation store p system))) - (#t - (let ((s (package-source p))) - (list (package-source-derivation store s)))) - (proc - (map (cut package-source-derivation store <>) - (proc p))))) + (let ((p (or (and graft? (package-replacement p)) p))) + (match src + (#f + (list (package->derivation store p system))) + (#t + (let ((s (package-source p))) + (list (package-source-derivation store s)))) + (proc + (map (cut package-source-derivation store <>) + (proc p)))))) ((? derivation? drv) (list drv)) ((? procedure? proc) diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 5821e509af..ae75bcfab0 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -43,6 +43,7 @@ trap "rm -rf $module_dir" EXIT cat > "$module_dir/foo.scm"< "$module_dir/foo.scm"<