Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
archive.hh File Reference

Go to the source code of this file.

Classes

struct  nix::PreparedDump
struct  nix::NARParseVisitor
struct  nix::NARParseVisitor::FileHandle
struct  nix::nar::File
struct  nix::nar::Directory
struct  nix::nar_index::File
struct  nix::nar_index::Directory

Typedefs

using nix::nar::Entry = std::variant<File, Symlink, Directory>
using nix::nar_index::Entry = std::variant<File, Symlink, Directory>

Functions

WireFormatGenerator nix::dumpPath (Path path, PathFilter &filter)
WireFormatGenerator nix::dumpPath (Path path)
WireFormatGenerator nix::dumpPathAndGetMtime (Path path, time_t &mtime)
box_ptr< PreparedDumpnix::prepareDump (Path path)
box_ptr< PreparedDumpnix::prepareDump (Path path, PathFilter &filter)
WireFormatGenerator nix::dumpString (std::string_view s)
WireFormatGenerator nix::nar::dump (Entry nar)
Generator< Entry > nix::nar::parse (Source &source)
Entry nix::nar_index::create (Source &source)
kj::Promise< Result< Entry > > nix::nar_index::create (AsyncInputStream &source)
void nix::parseDump (NARParseVisitor &sink, Source &source)
kj::Promise< Result< void > > nix::parseDump (NARParseVisitor &sink, AsyncInputStream &source)
void nix::restorePath (const Path &path, Source &source)
kj::Promise< Result< void > > nix::restorePath (const Path &path, AsyncInputStream &source)
WireFormatGenerator nix::copyNAR (Source &source)
box_ptr< AsyncInputStreamnix::copyNAR (AsyncInputStream &source)

Variables

constexpr std::string_view nix::narVersionMagic1 = "nix-archive-1"
constexpr std::string_view nix::caseHackSuffix = "~nix~case~hack~"

Function Documentation

◆ copyNAR()

WireFormatGenerator nix::copyNAR ( Source & source)

Read a NAR from 'source' and return it as a generator.

◆ dumpPath()

WireFormatGenerator nix::dumpPath ( Path path,
PathFilter & filter )

dumpPath creates a Nix archive of the specified path.

Parameters
paththe file system data to dump. Dumping is recursive so if this is a directory we dump it and all its children.
[out]sinkThe serialised archive is fed into this sink.
filterCan be used to skip certain files.

The format is as follows:

IF path points to a REGULAR FILE:
dump(path) = attrs(
[ ("type", "regular")
, ("contents", contents(path))
])
IF path points to a DIRECTORY:
dump(path) = attrs(
[ ("type", "directory")
, ("entries", concat(map(f, sort(entries(path)))))
])
where f(fn) = attrs(
[ ("name", fn)
, ("file", dump(path + "/" + fn))
])
where:
attrs(as) = concat(map(attr, as)) + encN(0)
attrs((a, b)) = encS(a) + encS(b)
encS(s) = encN(len(s)) + s + (padding until next 64-bit boundary)
encN(n) = 64-bit little-endian encoding of n.
contents(path) = the contents of a regular file.
sort(strings) = lexicographic sort by 8-bit value (strcmp).
entries(path) = the entries of a directory, without `.` and
`..`.
`+` denotes string concatenation.

◆ dumpPathAndGetMtime()

WireFormatGenerator nix::dumpPathAndGetMtime ( Path path,
time_t & mtime )

Same as dumpPath(), but returns the last modified date of the path.

◆ dumpString()

WireFormatGenerator nix::dumpString ( std::string_view s)

Dump an archive with a single file with these contents.

Parameters
sContents of the file.

◆ parse()

Generator< Entry > nix::nar::parse ( Source & source)

Parse a NAR from a source. The returned generator is guaranteed to produce only a single Entry but must be explicity read to exhaustion regardless to consume the entire nar from the source. Stopping before Generator::next() returns std::nullopt will not reading trailing metadata.