hnix-store-core-0.4.2.0: Core effects for interacting with the Nix store.
Safe HaskellNone
LanguageHaskell2010

System.Nix.Nar

Synopsis

Encoding and Decoding NAR archives

buildNarIO :: NarEffects IO -> FilePath -> Handle -> IO () Source #

Pack the filesystem object at FilePath into a NAR and stream it into the IO.Handle The handle should aleady be open and in IO.WriteMode.

unpackNarIO :: NarEffects IO -> Handle -> FilePath -> IO (Either String ()) Source #

Read NAR formatted bytes from the IO.Handle and unpack them into file system object(s) at the supplied FilePath

Experimental

parseNar :: (MonadIO m, MonadFail m) => NarParser m () Source #

Parse a NAR byte string, producing (). Parsing a NAR is mostly used for its side-effect: producing the file system objects packed in the NAR. That's why we pure ()

Filesystem capabilities used by NAR encoder/decoder

data NarEffects (m :: * -> *) Source #

Instances

Instances details
Monad m => MonadReader (NarEffects m) (NarParser m) Source # 
Instance details

Defined in System.Nix.Internal.Nar.Parser

Methods

ask :: NarParser m (NarEffects m) #

local :: (NarEffects m -> NarEffects m) -> NarParser m a -> NarParser m a #

reader :: (NarEffects m -> a) -> NarParser m a #

narEffectsIO :: (MonadIO m, MonadFail m, MonadBaseControl IO m) => NarEffects m Source #

A particular NarEffects that uses regular POSIX for file manipulation You would replace this with your own NarEffects if you wanted a different backend

Internal

streamNarIO :: forall m. MonadIO m => (ByteString -> m ()) -> NarEffects IO -> FilePath -> m () Source #

This implementation of Nar encoding takes an arbitrary yield function from any streaming library, and repeatedly calls it while traversing the filesystem object to Nar encode

runParser Source #

Arguments

:: forall m a. (MonadIO m, MonadBaseControl IO m) 
=> NarEffects m

Provide the effects set, usually narEffectsIO

-> NarParser m a

A parser to run, such as parseNar

-> Handle

A handle the stream containg the NAR. It should already be open and in IO.ReadMode

-> FilePath

The root file system object to be created by the NAR

-> m (Either String a) 

Run a NarParser over a byte stream This is suitable for testing the top-level NAR parser, or any of the smaller utilities parsers, if you have bytes appropriate for them