mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
remote: NixDaemonSpec pass StoreConnection, StoreDir
This commit is contained in:
parent
8eb0059576
commit
30baaf3db2
@ -104,11 +104,8 @@ error: changing ownership of path '/run/user/1000/test-nix-store-06b0d249e561612
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
startDaemon
|
startDaemon
|
||||||
:: ( MonadIO m
|
:: FilePath -- ^ Temporary directory
|
||||||
, MonadMask m
|
-> IO (ProcessHandle, StoreConnection)
|
||||||
)
|
|
||||||
=> FilePath
|
|
||||||
-> IO (ProcessHandle, RemoteStoreT m a -> Run m a)
|
|
||||||
startDaemon fp = do
|
startDaemon fp = do
|
||||||
writeConf (fp </> "etc" </> "nix.conf")
|
writeConf (fp </> "etc" </> "nix.conf")
|
||||||
procHandle <-
|
procHandle <-
|
||||||
@ -119,10 +116,8 @@ startDaemon fp = do
|
|||||||
|
|
||||||
waitSocket sockFp 30
|
waitSocket sockFp 30
|
||||||
pure ( procHandle
|
pure ( procHandle
|
||||||
, runStoreConnection (StoreConnection_Socket (StoreSocketPath sockFp))
|
, StoreConnection_Socket
|
||||||
. (setStoreDir (StoreDir $ Data.ByteString.Char8.pack $ fp </> "store")
|
$ StoreSocketPath sockFp
|
||||||
>>
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
sockFp = fp </> "var/nix/daemon-socket/socket"
|
sockFp = fp </> "var/nix/daemon-socket/socket"
|
||||||
@ -150,13 +145,10 @@ enterNamespaces = do
|
|||||||
[ GroupMapping 0 gid 1 ]
|
[ GroupMapping 0 gid 1 ]
|
||||||
True
|
True
|
||||||
|
|
||||||
withNixDaemon
|
withNixDaemon'
|
||||||
:: ( MonadIO m
|
:: (FilePath -> StoreDir -> StoreConnection -> IO a)
|
||||||
, MonadMask m
|
|
||||||
)
|
|
||||||
=> ((RemoteStoreT m a -> Run m a) -> IO a)
|
|
||||||
-> IO a
|
-> IO a
|
||||||
withNixDaemon action =
|
withNixDaemon' action =
|
||||||
System.IO.Temp.withSystemTempDirectory "test-nix-store" $ \path -> do
|
System.IO.Temp.withSystemTempDirectory "test-nix-store" $ \path -> do
|
||||||
|
|
||||||
mapM_ (System.Directory.createDirectory . snd)
|
mapM_ (System.Directory.createDirectory . snd)
|
||||||
@ -176,11 +168,29 @@ withNixDaemon action =
|
|||||||
writeFile (path </> "dummy") "Hello World"
|
writeFile (path </> "dummy") "Hello World"
|
||||||
|
|
||||||
System.Directory.setCurrentDirectory path
|
System.Directory.setCurrentDirectory path
|
||||||
|
let storeDir =
|
||||||
|
StoreDir
|
||||||
|
$ Data.ByteString.Char8.pack
|
||||||
|
$ path </> "store"
|
||||||
|
|
||||||
Control.Exception.bracket
|
Control.Exception.bracket
|
||||||
(startDaemon path)
|
(startDaemon path)
|
||||||
(System.Process.terminateProcess . fst)
|
(System.Process.terminateProcess . fst)
|
||||||
(action . snd)
|
(action path storeDir . snd)
|
||||||
|
|
||||||
|
withNixDaemon
|
||||||
|
:: ( MonadIO m
|
||||||
|
, MonadMask m
|
||||||
|
)
|
||||||
|
=> ((RemoteStoreT m a -> Run m a) -> IO a)
|
||||||
|
-> IO a
|
||||||
|
withNixDaemon action =
|
||||||
|
withNixDaemon' $ \_tmpPath storeDir storeConn ->
|
||||||
|
action $ \a ->
|
||||||
|
runStoreConnection storeConn
|
||||||
|
( setStoreDir storeDir
|
||||||
|
>> a
|
||||||
|
)
|
||||||
|
|
||||||
checks
|
checks
|
||||||
:: ( Show a
|
:: ( Show a
|
||||||
|
Loading…
Reference in New Issue
Block a user