aboutsummaryrefslogtreecommitdiff
#pragma once

#include "types.hh"
#include "serialise.hh"


namespace nix {


/* dumpPath creates a Nix archive of the specified path.  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. */

struct PathFilter
{
    virtual ~PathFilter() { }
    virtual bool operator () (const Path & path) { return true; }
};

extern PathFilter defaultPathFilter;

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

struct ParseSink
{
    virtual void createDirectory(const Path & path) { };

    virtual void createRegularFile(const Path & path) { };
    virtual void isExecutable() { };
    virtual void preallocateContents(unsigned long long size) { };
    virtual void receiveContents(unsigned char * data, unsigned int len) { };

    virtual void createSymlink(const Path & path, const string & target) { };
};

void parseDump(ParseSink & sink, Source & source);

void restorePath(const Path & path, Source & source);

}
ew systemd files. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Thiago Jung Bauermann 2021-05-10.gitignore: Ignore .mo files....* .gitignore: Ignore files matching the *.mo pattern. Maxim Cournoyer 2021-05-05.gitignore: Ignore .tarball-ignore....This file can be useful to fix a version string when experimenting with 'make release'. * .gitignore: Add a pattern to ignore .tarball-version. Maxim Cournoyer 2021-04-23.gitignore: Ignore release artifacts....Not ignoring these in the tree leads to the next generated version (.version) being suffixed with '-dirty', which confuses things. * .gitignore [/guix-*]: New pattern. [/doc/stamp-[0-9]]: Adjust to ... [/doc/stamp-*]: ... this. [/release-*]: New pattern. Maxim Cournoyer 2021-04-23.gitignore: Ignore generated .pot files....These files are automatically-extracted templates rather than source, hence shouldn't be checked in. * .gitignore: Add a glob pattern to ignore .pot files. Maxim Cournoyer 2020-10-20gitignore: Ignore generated guile binary and intermediate products....* .gitignore: Ignore guile, guile-guile-launcher.o, .deps and .dirstamp. Julien Lepiller 2020-09-17guix-install.sh: Support OpenRC....* etc/guix-install.sh (chk_init_sys): Detect OpenRC. (sys_enable_guix_daemon): Install & enable the Guix daemon on such systems. * etc/openrc/guix-daemon.in: New file. * nix/local.mk: Add a rule for it. (openrcservicedir, nodist_openrcservice_DATA): New variables. (CLEANFILES, EXTRA_DIST): Add them. * .gitignore: Ignore etc/openrc/guix-daemon. Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr> Morgan Smith