From 1cad3476189d2ce84fabe95b69db8fb85a10b67a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 7 Mar 2022 19:03:15 +0100 Subject: derivations: Coalesce inputs that have the same output path. Fixes . * guix/derivations.scm (coalesce-duplicate-inputs): Use the output paths of DRV as a hash table key. * tests/derivations.scm ("derivation with duplicate fixed-output inputs"): Expect a single input for FINAL. ("derivation with equivalent fixed-output inputs"): New test. --- guix/derivations.scm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/guix/derivations.scm b/guix/derivations.scm index f77ea179f4..354ec20e3f 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -245,11 +245,19 @@ Nix itself keeps only one of them." (make-hash-table 25)) (for-each (lambda (input) - (let* ((drv (derivation-input-path input)) + ;; If DRV1 and DRV2 are fixed-output derivations with the same + ;; output path, they must be coalesced. Thus, TABLE is keyed by + ;; output paths. + (let* ((drv (derivation-input-derivation input)) + (key (string-join + (map (match-lambda + ((_ . output) + (derivation-output-path output))) + (derivation-outputs drv)))) (sub-drvs (derivation-input-sub-derivations input))) - (match (hash-get-handle table drv) + (match (hash-get-handle table key) (#f - (hash-set! table drv input)) + (hash-set! table key input)) ((and handle (key . ($ drv sub-drvs2))) ;; Merge DUP with INPUT. (let* ((sub-drvs (delete-duplicates -- cgit v1.2.3