diff --git a/hnix-store-remote/src/System/Nix/Store/Remote/Arbitrary.hs b/hnix-store-remote/src/System/Nix/Store/Remote/Arbitrary.hs index 56e39b1..a487fa1 100644 --- a/hnix-store-remote/src/System/Nix/Store/Remote/Arbitrary.hs +++ b/hnix-store-remote/src/System/Nix/Store/Remote/Arbitrary.hs @@ -78,9 +78,6 @@ deriving via GenericArbitrary GCAction deriving via GenericArbitrary GCOptions instance Arbitrary GCOptions -deriving via GenericArbitrary GCResult - instance Arbitrary GCResult - -- * Handshake deriving via GenericArbitrary WorkerMagic @@ -94,6 +91,8 @@ deriving via GenericArbitrary TrustedFlag deriving via GenericArbitrary WorkerOp instance Arbitrary WorkerOp +-- ** Request + instance Arbitrary (Some StoreRequest) where arbitrary = oneof [ Some <$> (AddToStore <$> arbitrary <*> arbitrary <*> arbitrary <*> pure RepairMode_DontRepair) @@ -121,3 +120,11 @@ instance Arbitrary (Some StoreRequest) where , pure $ Some SyncWithGC , Some <$> (VerifyStore <$> arbitrary <*> arbitrary) ] + +-- ** Reply + +deriving via GenericArbitrary GCResult + instance Arbitrary GCResult + +deriving via GenericArbitrary Missing + instance Arbitrary Missing diff --git a/hnix-store-remote/src/System/Nix/Store/Remote/Serializer.hs b/hnix-store-remote/src/System/Nix/Store/Remote/Serializer.hs index c5fd1b3..39ca8ac 100644 --- a/hnix-store-remote/src/System/Nix/Store/Remote/Serializer.hs +++ b/hnix-store-remote/src/System/Nix/Store/Remote/Serializer.hs @@ -92,6 +92,8 @@ module System.Nix.Store.Remote.Serializer , buildResult -- *** GCResult , gcResult + -- *** Missing + , missing ) where import Control.Monad.Except (MonadError, throwError, ) @@ -1341,6 +1343,7 @@ data ReplySError | ReplySError_PrimPut SError | ReplySError_DerivationOutput SError | ReplySError_GCResult SError + | ReplySError_Missing SError | ReplySError_Realisation SError | ReplySError_RealisationWithId SError deriving (Eq, Ord, Generic, Show) @@ -1453,3 +1456,23 @@ gcResult = mapErrorS ReplySError_GCResult $ Serializer putS int gcResultBytesFreed putS (int @Word64) 0 -- obsolete } + +missing + :: HasStoreDir r + => NixSerializer r ReplySError Missing +missing = mapErrorS ReplySError_Missing $ Serializer + { getS = do + missingWillBuild <- getS (hashSet storePath) + missingWillSubstitute <- getS (hashSet storePath) + missingUnknownPaths <- getS (hashSet storePath) + missingDownloadSize <- getS int + missingNarSize <- getS int + + pure Missing{..} + , putS = \Missing{..} -> do + putS (hashSet storePath) missingWillBuild + putS (hashSet storePath) missingWillSubstitute + putS (hashSet storePath) missingUnknownPaths + putS int missingDownloadSize + putS int missingNarSize + } diff --git a/hnix-store-remote/src/System/Nix/Store/Remote/Types/StoreReply.hs b/hnix-store-remote/src/System/Nix/Store/Remote/Types/StoreReply.hs index 94fa2c0..185147d 100644 --- a/hnix-store-remote/src/System/Nix/Store/Remote/Types/StoreReply.hs +++ b/hnix-store-remote/src/System/Nix/Store/Remote/Types/StoreReply.hs @@ -6,6 +6,7 @@ import System.Nix.Build (BuildResult) import System.Nix.StorePath (HasStoreDir(..), StorePath) import System.Nix.Store.Remote.Serializer import System.Nix.Store.Remote.Types.GC (GCResult) +import System.Nix.Store.Remote.Types.Query.Missing (Missing) import System.Nix.Store.Remote.Types.ProtoVersion (HasProtoVersion) -- | Get @NixSerializer@ for some type @a@ @@ -29,6 +30,9 @@ instance StoreReply BuildResult where instance StoreReply GCResult where getReplyS = gcResult +instance StoreReply Missing where + getReplyS = missing + instance StoreReply StorePath where getReplyS = mapPrimE storePath diff --git a/hnix-store-remote/tests/NixSerializerSpec.hs b/hnix-store-remote/tests/NixSerializerSpec.hs index e50a1f0..d2ba74d 100644 --- a/hnix-store-remote/tests/NixSerializerSpec.hs +++ b/hnix-store-remote/tests/NixSerializerSpec.hs @@ -151,6 +151,7 @@ spec = parallel $ do describe "StoreReply" $ do prop "GCResult" $ roundtripSReader @StoreDir gcResult + prop "Missing" $ roundtripSReader @StoreDir missing restrictProtoVersion :: ProtoVersion -> Some StoreRequest -> Bool restrictProtoVersion v (Some (BuildPaths _ _)) | v < ProtoVersion 1 30 = False