From cee9c9c09961e7e95518e37c6cd6fb36b7da45f6 Mon Sep 17 00:00:00 2001 From: Oleh Stolyar Date: Mon, 26 Aug 2019 23:21:48 +0100 Subject: [PATCH] hnix-store-remote: implement `buildPaths` op I was hoping to use the `StorePath` type from `System.Nix.StorePath`, but I am not sure how to construct its values at runtime. I ended up giving `buildPaths` a simpler type that expects a list of bytestrings. --- .../src/System/Nix/Store/Remote.hs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/hnix-store-remote/src/System/Nix/Store/Remote.hs b/hnix-store-remote/src/System/Nix/Store/Remote.hs index 8d9913dd..fb347b7a 100644 --- a/hnix-store-remote/src/System/Nix/Store/Remote.hs +++ b/hnix-store-remote/src/System/Nix/Store/Remote.hs @@ -6,14 +6,17 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module System.Nix.Store.Remote ( - runStore + BuildMode(..) + , runStore , syncWithGC , optimiseStore , verifyStore + , buildPaths ) where -import Control.Monad - +import Data.Binary.Put (Put, putInthost) +import Data.ByteString (ByteString) +import System.Nix.Util import System.Nix.Store.Remote.Types import System.Nix.Store.Remote.Protocol import System.Nix.Store.Remote.Util @@ -31,3 +34,24 @@ verifyStore :: CheckFlag -> RepairFlag -> MonadStore () verifyStore check repair = runOpArgs_ VerifyStore $ do putBool check putBool repair + +data BuildMode = Normal | Repair | Check + deriving (Eq, Show) + +putBuildMode :: BuildMode -> Put +putBuildMode mode = putInthost $ + case mode of + Normal -> 0 + Repair -> 1 + Check -> 2 + +buildPaths :: + -- forall storeDir . (KnownStoreDir storeDir) => + -- [StorePath storeDir] + [ByteString] -> BuildMode -> MonadStore () +buildPaths drvs mode = + runOpArgs_ BuildPaths args + where + args = do + putByteStrings drvs + putBuildMode mode