@@ -104,11 +104,8 @@ error: changing ownership of path '/run/user/1000/test-nix-store-06b0d249e561612
104104-}
105105
106106startDaemon
107- :: ( MonadIO m
108- , MonadMask m
109- )
110- => FilePath
111- -> IO (ProcessHandle , RemoteStoreT m a -> Run m a )
107+ :: FilePath -- ^ Temporary directory
108+ -> IO (ProcessHandle , StoreConnection )
112109startDaemon fp = do
113110 writeConf (fp </> " etc" </> " nix.conf" )
114111 procHandle <-
@@ -119,10 +116,8 @@ startDaemon fp = do
119116
120117 waitSocket sockFp 30
121118 pure ( procHandle
122- , runStoreConnection (StoreConnection_Socket (StoreSocketPath sockFp))
123- . (setStoreDir (StoreDir $ Data.ByteString.Char8. pack $ fp </> " store" )
124- >>
125- )
119+ , StoreConnection_Socket
120+ $ StoreSocketPath sockFp
126121 )
127122 where
128123 sockFp = fp </> " var/nix/daemon-socket/socket"
@@ -150,13 +145,10 @@ enterNamespaces = do
150145 [ GroupMapping 0 gid 1 ]
151146 True
152147
153- withNixDaemon
154- :: ( MonadIO m
155- , MonadMask m
156- )
157- => ((RemoteStoreT m a -> Run m a ) -> IO a )
148+ withNixDaemon'
149+ :: (FilePath -> StoreDir -> StoreConnection -> IO a )
158150 -> IO a
159- withNixDaemon action =
151+ withNixDaemon' action =
160152 System.IO.Temp. withSystemTempDirectory " test-nix-store" $ \ path -> do
161153
162154 mapM_ (System.Directory. createDirectory . snd )
@@ -176,11 +168,29 @@ withNixDaemon action =
176168 writeFile (path </> " dummy" ) " Hello World"
177169
178170 System.Directory. setCurrentDirectory path
171+ let storeDir =
172+ StoreDir
173+ $ Data.ByteString.Char8. pack
174+ $ path </> " store"
179175
180176 Control.Exception. bracket
181177 (startDaemon path)
182178 (System.Process. terminateProcess . fst )
183- (action . snd )
179+ (action path storeDir . snd )
180+
181+ withNixDaemon
182+ :: ( MonadIO m
183+ , MonadMask m
184+ )
185+ => ((RemoteStoreT m a -> Run m a ) -> IO a )
186+ -> IO a
187+ withNixDaemon action =
188+ withNixDaemon' $ \ _tmpPath storeDir storeConn ->
189+ action $ \ a ->
190+ runStoreConnection storeConn
191+ ( setStoreDir storeDir
192+ >> a
193+ )
184194
185195checks
186196 :: ( Show a
0 commit comments