Skip to content

Commit f60ebd5

Browse files
committed
Fix narInfoFileFor and add CA to narinfo
1 parent f31dc6c commit f60ebd5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

hnix-store-s3/src/System/Nix/Store/S3.hs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ upsertFile bucketName pth d mimeType =
4141
send (putObject bucketName (ObjectKey pth) (toBody d) & poContentType ?~ mimeType)
4242

4343
data NarInfo
44-
= NarInfo Path BS.ByteString BS.ByteString (Digest 'SHA256) Int (Digest 'SHA256) Int
44+
= NarInfo Path BS.ByteString BS.ByteString (Digest 'SHA256) Int (Digest 'SHA256) Int Text
4545

4646
narInfoToString
4747
:: Text
4848
-> NarInfo
4949
-> BS.ByteString
50-
narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash' narSize') =
50+
narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash' narSize' ca') =
5151
BS.unlines
5252
[ "StorePath: " <> E.encodeUtf8 (pathToText storeDir pth)
5353
, "URL: " <> url
@@ -57,14 +57,14 @@ narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash'
5757
, "NarHash: " <> E.encodeUtf8 (digestText32 narHash')
5858
, "NarSize: " <> fromString (show narSize')
5959
, "References: "
60+
, "CA: " <> E.encodeUtf8 ca'
6061
]
6162

6263
narInfoFileFor
63-
:: Text
64-
-> Path
64+
:: Path
6565
-> Text
66-
narInfoFileFor storeDir pth =
67-
pathToText storeDir pth <> ".narinfo"
66+
narInfoFileFor (Path h _) =
67+
printAsBase32 h <> ".narinfo"
6868

6969
addToStore
7070
:: Text
@@ -99,9 +99,18 @@ addToStore storeDir bucketName name pth recursive pfilter repair = do
9999
narCompressed = nar & lazy %~ compress
100100
url = "nar/" <> printAsBase32 fileHash <> ".nar.xz"
101101
fileHash = hash @'SHA256 narCompressed
102-
narInfo = NarInfo pth' (E.encodeUtf8 url) "xz" fileHash (BS.length narCompressed) (hash @'SHA256 nar) (BS.length nar)
102+
narInfo =
103+
NarInfo
104+
pth'
105+
(E.encodeUtf8 url)
106+
"xz"
107+
fileHash
108+
(BS.length narCompressed)
109+
(hash @'SHA256 nar)
110+
(BS.length nar)
111+
(makeFixedOutputCA recursive h)
103112

104113
void . lift $ upsertFile bucketName url narCompressed "application/x-nix-nar"
105-
void . lift $ upsertFile bucketName (narInfoFileFor storeDir pth') (narInfoToString storeDir narInfo) "text/x-nix-narinfo"
114+
void . lift $ upsertFile bucketName (narInfoFileFor pth') (narInfoToString storeDir narInfo) "text/x-nix-narinfo"
106115

107116
pure pth'

overlay.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ huper: helf: {
33
helf.callCabal2nix "hnix-store-core" ./hnix-store-core {};
44
hnix-store-remote =
55
helf.callCabal2nix "hnix-store-remote" ./hnix-store-remote {};
6+
hnix-store-s3 =
7+
helf.callCabal2nix "hnix-store-s3" ./hnix-store-s3 {};
68
}

0 commit comments

Comments
 (0)