Rosenthal/modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch
Hilton Chain 921ea4f87c
rosenthal: guix/hako: Fix URL for uncompressed nars in narinfo files.
* modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch:
Use nar/none URL for uncompressed nars.
2025-08-25 01:20:25 +08:00

104 lines
4.1 KiB
Diff

From b05b945ef65c401fc499d8be65d2431749b97980 Mon Sep 17 00:00:00 2001
Message-ID: <b05b945ef65c401fc499d8be65d2431749b97980.1756056002.git.hako@ultrarare.space>
From: Hilton Chain <hako@ultrarare.space>
Date: Sat, 23 Aug 2025 14:07:19 +0800
Subject: [PATCH] publish: Store cache in a layout identical to HTTP endpoints.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows serving substitutes using a file server.
Original layout:
--8<---------------cut here---------------start------------->8---
/path/to/publish/cache
├── hashes
│ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb
│ └── ql2nxr2b587kjydfwivjsnhmqya957bq
└── nar
├── none
│ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2.narinfo
│ └── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2.nar
└── zstd
├── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1.narinfo
└── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1.nar
--8<---------------cut here---------------end--------------->8---
Modified layout:
--8<---------------cut here---------------start------------->8---
/path/to/publish/cache
├── hashes
│ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb
│ └── ql2nxr2b587kjydfwivjsnhmqya957bq
├── nar
│ ├── none
│ │ └── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2
│ └── zstd
│ └── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1
├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb.narinfo
└── ql2nxr2b587kjydfwivjsnhmqya957bq.narinfo
--8<---------------cut here---------------end--------------->8---
Change-Id: I07689f08eef23c5cd4494451678f4e1ad709f1b3
---
guix/scripts/publish.scm | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index e9c69336392..62875c926a0 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -307,8 +307,6 @@ (define* (store-item->recutils store-item
(let ((url (encode-and-join-uri-path
`(,@(split-and-decode-uri-path nar-path)
,@(match compression
- (($ <compression> 'none)
- '())
(($ <compression> type)
(list (symbol->string type))))
,(basename store-item)))))
@@ -425,16 +423,13 @@ (define* (render-narinfo store request hash
(define* (nar-cache-file directory item
#:key (compression %no-compression))
- (string-append directory "/"
+ (string-append directory "/nar/"
(symbol->string (compression-type compression))
- "/" (basename item) ".nar"))
+ "/" (basename item)))
(define* (narinfo-cache-file directory item
#:key (compression %no-compression))
- (string-append directory "/"
- (symbol->string (compression-type compression))
- "/" (basename item)
- ".narinfo"))
+ (string-append directory "/" (string-take (basename item) 32) ".narinfo"))
(define (hash-part-mapping-cache-file directory hash)
(string-append directory "/hashes/" hash))
@@ -534,9 +529,7 @@ (define* (render-narinfo/cached store request hash
requested using POOL."
(define (delete-entry narinfo)
;; Delete NARINFO and the corresponding nar from CACHE.
- (let* ((nar (string-append (string-drop-right narinfo
- (string-length ".narinfo"))
- ".nar"))
+ (let* ((nar (string-drop-right narinfo (string-length ".narinfo")))
(base (basename narinfo ".narinfo"))
(hash (string-take base (string-index base #\-)))
(mapping (hash-part-mapping-cache-file cache hash)))
@@ -1043,6 +1036,7 @@ (define (string->compression-type string)
("gzip" 'gzip)
("lzip" 'lzip)
("zstd" 'zstd)
+ ("none" 'none)
(_ #f)))
(define (effective-compression requested-type compressions)
base-commit: 4e2e5c71cbf4a219682e77dfb8b9ac8709461999
--
2.51.0