HORIZON HASKELLDocslts/ghc-10.0.xc62e4de2026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · c62e4de · 2026-10-19

Encoding and Decoding NAR archives

2 declarations
valuebuildNarIO :: NarEffects IO -> FilePath -> Handle -> IO ()
#

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.

Experimental

3 declarations
valueparseNar :: (MonadIO m, MonadFail m) => NarParser m ()
#

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

4 declarations
datadata NarEffects (m :: Type -> Type)
#
datadata NarOptions
#

Options for configuring how NAR files are encoded and decoded.

Constructors

  • NarOptions
    • optUseCaseHack :: Bool

      Whether 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

6 declarations

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

valuerunParser
  1. :: (MonadIO m, MonadBaseControl IO m)
  2. => NarEffects m

    Provide the effects set, usually narEffectsIO

  3. -> NarParser m a

    A parser to run, such as parseNar

  4. -> Handle

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

  5. -> FilePath

    The root file system object to be created by the NAR

  6. -> 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

valuedumpPath
  1. :: MonadIO m
  2. => FilePath

    path for the file you want to dump to nar

  3. -> NarSource m

    the nar result in CPS style

#

dumpPath shorthand build a Source that turn file path to nar using the default narEffectsIO.

Type

1 declaration
typetype NarSource (m :: Type -> Type) = (ByteString -> m ()) -> m ()
#

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.