{-# language ScopedTypeVariables #-}
{-# language TypeFamilies #-}
module System.Nix.Nar
(
buildNarIO
, unpackNarIO
, Nar.parseNar
, Nar.testParser
, Nar.testParser'
, Nar.NarEffects(..)
, Nar.narEffectsIO
, Nar.streamNarIO
, Nar.runParser
, Nar.dumpString
, Nar.dumpPath
, Nar.NarSource
)
where
import qualified Control.Concurrent as Concurrent
import qualified Data.ByteString as BS
import qualified System.IO as IO
import qualified System.Nix.Internal.Nar.Effects as Nar
import qualified System.Nix.Internal.Nar.Parser as Nar
import qualified System.Nix.Internal.Nar.Streamer as Nar
buildNarIO
:: Nar.NarEffects IO
-> FilePath
-> IO.Handle
-> IO ()
buildNarIO :: NarEffects IO -> FilePath -> Handle -> IO ()
buildNarIO NarEffects IO
effs FilePath
basePath Handle
outHandle =
forall (m :: * -> *).
MonadIO m =>
NarEffects IO -> FilePath -> NarSource m
Nar.streamNarIO
NarEffects IO
effs
FilePath
basePath
(\ByteString
chunk -> Handle -> ByteString -> IO ()
BS.hPut Handle
outHandle ByteString
chunk forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> IO ()
Concurrent.threadDelay Int
10)
unpackNarIO
:: Nar.NarEffects IO
-> IO.Handle
-> FilePath
-> IO (Either String ())
unpackNarIO :: NarEffects IO -> Handle -> FilePath -> IO (Either FilePath ())
unpackNarIO NarEffects IO
effs = forall (m :: * -> *) a.
(MonadIO m, MonadBaseControl IO m) =>
NarEffects m
-> NarParser m a -> Handle -> FilePath -> m (Either FilePath a)
Nar.runParser NarEffects IO
effs forall (m :: * -> *). (MonadIO m, MonadFail m) => NarParser m ()
Nar.parseNar