Pack the filesystem object at FilePath into a NAR and stream it into the
IO.Handle
The handle should aleady be open and in WriteMode.
Modulehnix-store-nar-0.1.2.0Haskell2010
System.Nix.Nar
Contents
Synopsis
- value buildNarIO
- value unpackNarIO
- value parseNar
- value testParser
- value testParser'
- data NarEffects
- value narEffectsIO
- data NarOptions
- value defaultNarOptions
- value streamNarIO
- value streamNarIOWithOptions
- value runParser
- value runParserWithOptions
- value dumpString
- value dumpPath
- type NarSource
- Packagehnix-store-nar-0.1.2.0
- Exports16
- LanguageHaskell2010
- LicenceApache-2.0
- SourceNar.hs
Encoding and Decoding NAR archives
Read NAR formatted bytes from the IO.Handle and unpack them into
file system object(s) at the supplied FilePath
Experimental
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
Constructors
NarEffectsnarReadFile :: FilePath -> m ByteStringnarWriteFile :: FilePath -> IsExecutable -> ByteString -> m ()narStreamFile :: FilePath -> IsExecutable -> m (Maybe ByteString) -> m ()narListDir :: FilePath -> m [FilePath]narCreateDir :: FilePath -> m ()narCreateLink :: FilePath -> FilePath -> m ()narIsExec :: FilePath -> m IsExecutablenarIsDir :: FilePath -> m BoolnarIsSymLink :: FilePath -> m BoolnarFileSize :: FilePath -> m Int64narReadLink :: FilePath -> m FilePathnarDeleteDir :: FilePath -> m ()narDeleteFile :: FilePath -> m ()
A particular NarEffects that uses regular POSIX for file manipulation
You would replace this with your own NarEffects if you wanted a
different backend
Options for configuring how NAR files are encoded and decoded.
Constructors
NarOptionsoptUseCaseHack :: BoolWhether to enable a case hack to support case-insensitive filesystems. Equivalent to the 'use-case-hack' option in the Nix client.
The case hack rewrites file names to avoid collisions on case-insensitive file systems, e.g. APFS and HFS+ on macOS. Enabled by default on macOS (Darwin).
Internal
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 :: (MonadIO m, MonadBaseControl IO m)=> NarEffects mProvide the effects set, usually
narEffectsIO-> NarParser m aA parser to run, such as
parseNar-> HandleA handle the stream containg the NAR. It should already be open and in
ReadMode-> FilePathThe 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
runParserWithOptions :: (MonadIO m, MonadBaseControl IO m)=> NarOptions-> NarEffects mProvide the effects set, usually
narEffectsIO-> NarParser m aA parser to run, such as
parseNar-> HandleA handle the stream containg the NAR. It should already be open and in
ReadMode-> FilePathThe root file system object to be created by the NAR
-> m (Either String a)
dumpString :: MonadIO m=> ByteStringthe string you want to dump
-> NarSource mThe nar result in CPS style
dumpString dump a string to nar in CPS style. The function takes in a ByteString, and build a `NarSource m`.
dumpPath dumpPath shorthand build a Source that turn file path to nar using the default narEffectsIO.
Type
NarSource The source to provide nar to the handler `(ByteString -> m ())`. It is isomorphic to ByteString by Yoneda lemma if the result is meant to be m (). It is done in CPS style so IO can be chunks.