1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 21:50:58 +01:00
nix/src/libfetchers/input-accessor.hh
Eelco Dolstra 4b313ceb9e fetchTree: Support applying patches
You can now write

  fetchTree {
    type = "github";
    owner = "NixOS";
    repo = "nixpkgs";
    rev = "0f316e4d72daed659233817ffe52bf08e081b5de";
    patches = [ ./thunderbird-1.patch ./thunderbird-2.patch ];
  };

to apply a list of patches to a tree. These are applied lazily - the
patched tree is not materialized unless you do something that causes
the entire tree to be copied to the store (like 'src = fetchTree {
... }'). The equivalent of '-p1' is implied.

File additions/deletions/renames are not yet handled.

Issue #3920.
2022-03-29 11:01:14 +02:00

74 lines
1.5 KiB
C++

#pragma once
#include "ref.hh"
#include "types.hh"
#include "archive.hh"
namespace nix {
struct InputAccessor
{
const size_t number;
InputAccessor();
virtual ~InputAccessor()
{ }
virtual std::string readFile(PathView path) = 0;
virtual bool pathExists(PathView path) = 0;
enum Type { tRegular, tSymlink, tDirectory, tMisc };
struct Stat
{
Type type = tMisc;
//uint64_t fileSize = 0; // regular files only
bool isExecutable = false; // regular files only
};
virtual Stat lstat(PathView path) = 0;
typedef std::optional<Type> DirEntry;
typedef std::map<std::string, DirEntry> DirEntries;
virtual DirEntries readDirectory(PathView path) = 0;
virtual std::string readLink(PathView path) = 0;
virtual void dumpPath(
const Path & path,
Sink & sink,
PathFilter & filter = defaultPathFilter);
};
ref<InputAccessor> makeFSInputAccessor(
const Path & root,
std::optional<PathSet> && allowedPaths = {});
struct MemoryInputAccessor : InputAccessor
{
virtual void addFile(PathView path, std::string && contents) = 0;
};
ref<MemoryInputAccessor> makeMemoryInputAccessor();
ref<InputAccessor> makeZipInputAccessor(PathView path);
ref<InputAccessor> makePatchingInputAccessor(
ref<InputAccessor> next,
const std::vector<std::string> & patches);
struct SourcePath
{
ref<InputAccessor> accessor;
Path path;
std::string_view baseName() const;
};
std::ostream & operator << (std::ostream & str, const SourcePath & path);
}