#pragma once #include "types.hh" #include "hash.hh" #include "path.hh" #include namespace nix { class Store; } namespace nix::fetchers { struct Input; struct Tree { Path actualPath; StorePath storePath; Hash narHash; std::optional rev; std::optional revCount; std::optional lastModified; }; struct Input : std::enable_shared_from_this { std::string type; std::optional narHash; // FIXME: implement virtual ~Input() { } virtual bool operator ==(const Input & other) const { return false; } virtual bool isDirect() const { return true; } virtual bool isImmutable() const { return (bool) narHash; } virtual bool contains(const Input & other) const { return false; } virtual std::optional getRef() const { return {}; } virtual std::optional getRev() const { return {}; } virtual std::string to_string() const = 0; std::pair> fetchTree(ref store) const; virtual std::shared_ptr applyOverrides( std::optional ref, std::optional rev) const; virtual std::optional getSourcePath() const { return {}; } virtual void clone(const Path & destDir) const { throw Error("do not know how to clone input '%s'", to_string()); } private: virtual std::pair> fetchTreeInternal(ref store) const = 0; }; struct ParsedURL; struct InputScheme { virtual ~InputScheme() { } virtual std::unique_ptr inputFromURL(const ParsedURL & url) = 0; }; std::unique_ptr inputFromURL(const ParsedURL & url); std::unique_ptr inputFromURL(const std::string & url); void registerInputScheme(std::unique_ptr && fetcher); }