Skip to content

Commit 776d5ea

Browse files
stolyarolehOleh Stolyar
authored andcommitted
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.
1 parent 4914161 commit 776d5ea

File tree

1 file changed

+27
-3
lines changed
  • hnix-store-remote/src/System/Nix/Store

1 file changed

+27
-3
lines changed

hnix-store-remote/src/System/Nix/Store/Remote.hs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
{-# LANGUAGE ScopedTypeVariables #-}
77
{-# LANGUAGE TypeApplications #-}
88
module System.Nix.Store.Remote (
9-
runStore
9+
BuildMode(..)
10+
, runStore
1011
, syncWithGC
1112
, optimiseStore
1213
, verifyStore
14+
, buildPaths
1315
) where
1416

15-
import Control.Monad
16-
17+
import Data.Binary.Put (Put, putInthost)
18+
import Data.ByteString (ByteString)
19+
import System.Nix.Util
1720
import System.Nix.Store.Remote.Types
1821
import System.Nix.Store.Remote.Protocol
1922
import System.Nix.Store.Remote.Util
@@ -31,3 +34,24 @@ verifyStore :: CheckFlag -> RepairFlag -> MonadStore ()
3134
verifyStore check repair = runOpArgs_ VerifyStore $ do
3235
putBool check
3336
putBool repair
37+
38+
data BuildMode = Normal | Repair | Check
39+
deriving (Eq, Show)
40+
41+
putBuildMode :: BuildMode -> Put
42+
putBuildMode mode = putInthost $
43+
case mode of
44+
Normal -> 0
45+
Repair -> 1
46+
Check -> 2
47+
48+
buildPaths ::
49+
-- forall storeDir . (KnownStoreDir storeDir) =>
50+
-- [StorePath storeDir]
51+
[ByteString] -> BuildMode -> MonadStore ()
52+
buildPaths drvs mode =
53+
runOpArgs_ BuildPaths args
54+
where
55+
args = do
56+
putByteStrings drvs
57+
putBuildMode mode

0 commit comments

Comments
 (0)