Skip to content

Commit

Permalink
remote: change AddSignatures from [ByteString] to Set Signature
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Dec 2, 2023
1 parent 05afb32 commit f28afe8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
3 changes: 2 additions & 1 deletion hnix-store-remote/src/System/Nix/Store/Remote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ queryPathInfoUncached path = do

let
sigs = case
Data.Set.fromList <$> mapM (Data.Attoparsec.Text.parseOnly System.Nix.Signature.signatureParser) sigStrings
Data.Set.fromList
<$> mapM System.Nix.Signature.parseNarSignature sigStrings
of
Left e -> error e
Right x -> x
Expand Down
43 changes: 29 additions & 14 deletions hnix-store-remote/src/System/Nix/Store/Remote/Serializer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module System.Nix.Store.Remote.Serializer
, storePathName
-- * Metadata
, pathMetadata
-- * Signatures
, signature
, narSignature
-- * Some HashAlgo
, someHashAlgo
-- * Digest
Expand Down Expand Up @@ -115,7 +118,7 @@ import System.Nix.ContentAddress (ContentAddress)
import System.Nix.Derivation (Derivation(..), DerivationOutput(..))
import System.Nix.DerivedPath (DerivedPath, ParseOutputsError)
import System.Nix.Hash (HashAlgo)
import System.Nix.Signature (NarSignature)
import System.Nix.Signature (Signature, NarSignature)
import System.Nix.StorePath (HasStoreDir(..), InvalidPathError, StorePath, StorePathHashPart, StorePathName)
import System.Nix.StorePath.Metadata (Metadata(..), StorePathTrust(..))
import System.Nix.Store.Remote.Types
Expand Down Expand Up @@ -505,7 +508,7 @@ pathMetadata = Serializer
size -> Just size) <$> getS int
trust <- getS storePathTrust

sigs <- getS $ set signature
sigs <- getS $ set narSignature
contentAddress <- getS maybeContentAddress

pure $ Metadata{..}
Expand All @@ -527,7 +530,7 @@ pathMetadata = Serializer
putS time registrationTime
putS int $ Prelude.maybe 0 id $ narBytes
putS storePathTrust trust
putS (set signature) sigs
putS (set narSignature) sigs
putS maybeContentAddress contentAddress
}
where
Expand All @@ -553,15 +556,27 @@ pathMetadata = Serializer
(\case BuiltElsewhere -> False; BuiltLocally -> True)
bool

signature
:: NixSerializer r SError NarSignature
signature =
mapPrismSerializer
(Data.Bifunctor.first SError_Signature
. Data.Attoparsec.Text.parseOnly
System.Nix.Signature.signatureParser)
(System.Nix.Signature.signatureToText)
text
-- * Signatures

signature
:: NixSerializer r SError Signature
signature =
mapPrismSerializer
(Data.Bifunctor.first SError_Signature
. Data.Attoparsec.Text.parseOnly
System.Nix.Signature.signatureParser)
(System.Nix.Signature.signatureToText)
text

narSignature
:: NixSerializer r SError NarSignature
narSignature =
mapPrismSerializer
(Data.Bifunctor.first SError_Signature
. Data.Attoparsec.Text.parseOnly
System.Nix.Signature.narSignatureParser)
(System.Nix.Signature.narSignatureToText)
text

-- * Some HashAlgo

Expand Down Expand Up @@ -982,7 +997,7 @@ storeRequest = Serializer

WorkerOp_AddSignatures -> do
path <- getS storePath
signatures <- getS (list byteString)
signatures <- getS (set signature)
pure $ Some (AddSignatures path signatures)

WorkerOp_AddIndirectRoot ->
Expand Down Expand Up @@ -1101,7 +1116,7 @@ storeRequest = Serializer
putS workerOp WorkerOp_AddSignatures

putS storePath path
putS (list byteString) signatures
putS (set signature) signatures

Some (AddIndirectRoot path) -> do
putS workerOp WorkerOp_AddIndirectRoot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import System.Nix.Build (BuildMode, BuildResult)
import System.Nix.Derivation (Derivation)
import System.Nix.DerivedPath (DerivedPath)
import System.Nix.Hash (HashAlgo)
import System.Nix.Signature (Signature)
import System.Nix.Store.Types (FileIngestionMethod, RepairMode)
import System.Nix.StorePath (StorePath, StorePathName, StorePathHashPart)
import System.Nix.StorePath.Metadata (Metadata)
Expand Down Expand Up @@ -58,7 +59,7 @@ data StoreRequest :: Type -> Type where

AddSignatures
:: StorePath
-> [ByteString]
-> Set Signature
-> StoreRequest ()

-- | Add temporary garbage collector root.
Expand Down

0 comments on commit f28afe8

Please sign in to comment.