From 1c230ec96e29e3f70ddf217e93c448f6f037a470 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 15 Jan 2026 18:19:40 +0000 Subject: [PATCH] scripts: substitute: Default to fast decompression. This changes the behaviour for the first one or few nars the substitute script downloads, with uncompressed and zstd compressed nars prefered rather than picking by file size. * guix/scripts/substitute.scm: (%default-fast-decompression?): Change to #t. * tests/substitute.scm ("substitute, preferred nar URL is 404, other is 200"): Adjust test. Change-Id: I89202f084cd6b9d506bcb3d46f75de690c6986b5 --- guix/scripts/substitute.scm | 2 +- tests/substitute.scm | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index b3a514815d..455f5a2346 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -223,7 +223,7 @@ Internal tool to substitute a pre-built binary to a local build.\n")) ;;; ;; Whether to initially prefer fast decompression or not -(define %default-fast-decompression? #f) +(define %default-fast-decompression? #t) (define (call-with-cpu-usage-monitoring thunk) (let ((before (times))) diff --git a/tests/substitute.scm b/tests/substitute.scm index 33a6d6040a..cd75d56b98 100644 --- a/tests/substitute.scm +++ b/tests/substitute.scm @@ -618,16 +618,30 @@ System: mips64el-linux\n"))) (with-narinfo* (string-append %narinfo "Signature: " (signature-field %narinfo)) %main-substitute-directory + (define (compress input output compression) + (call-with-output-file output + (lambda (port) + (call-with-compressed-output-port compression port + (lambda (port) + (call-with-input-file input + (lambda (input) + (dump-port input port)))))))) + + ;; This test is dependent on which nar the substitute script picks to + ;; request first (with-http-server `((200 ,(string-append %narinfo "Signature: " (signature-field %narinfo) "\n" "URL: example.nar.lz\n" "Compression: lzip\n")) (404 "Sorry, nar.lz is missing!") - (200 ,(call-with-input-file - (string-append %main-substitute-directory - "/example.nar") - get-bytevector-all))) + (200 ,(let ((nar (string-append + %main-substitute-directory + "/example.nar"))) + (compress nar (string-append nar ".lz") 'lzip) + (call-with-input-file + (string-append nar ".lz") + get-bytevector-all)))) (dynamic-wind (const #t) (lambda ()