Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
archive.hh File Reference
#include "types.hh"
#include "serialise.hh"
#include "fs-sink.hh"

Go to the source code of this file.

Functions

void nix::dumpPath (const Path &path, Sink &sink, PathFilter &filter)
 
time_t nix::dumpPathAndGetMtime (const Path &path, Sink &sink, PathFilter &filter)
 
void nix::dumpString (std::string_view s, Sink &sink)
 
void nix::parseDump (FileSystemObjectSink &sink, Source &source)
 
void nix::restorePath (const std::filesystem::path &path, Source &source, bool startFsync)
 
void nix::copyNAR (Source &source, Sink &sink)
 

Variables

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

Function Documentation

◆ copyNAR()

void nix::copyNAR ( Source & source,
Sink & sink )

Read a NAR from 'source' and write it to 'sink'.

◆ dumpPath()

void nix::dumpPath ( const Path & path,
Sink & sink,
PathFilter & filter = defaultPathFilter )

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.
boost::format f(fs)
return s
Definition lexer.l:459
const T & value
Definition lexer.l:492
Source & next
Definition lexer.l:3413
std::string path
Definition lexer.l:1399
std::string std::string_view std::string_view to
Definition lexer.l:2592

◆ dumpPathAndGetMtime()

time_t nix::dumpPathAndGetMtime ( const Path & path,
Sink & sink,
PathFilter & filter = defaultPathFilter )

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

◆ dumpString()

void nix::dumpString ( std::string_view s,
Sink & sink )

Dump an archive with a single file with these contents.

Parameters
sContents of the file.