18namespace nix {
class Store; }
20namespace nix::fetchers {
40 friend struct InputScheme;
42 std::shared_ptr<InputScheme> scheme;
53 static Input fromURL(
const std::string & url,
bool requireTree =
true);
55 static Input fromURL(
const ParsedURL & url,
bool requireTree =
true);
57 static Input fromAttrs(Attrs && attrs);
61 std::string toURLString(
const std::map<std::string, std::string> & extraQuery = {})
const;
63 std::string to_string()
const;
65 Attrs toAttrs()
const;
88 bool operator ==(
const Input & other)
const;
90 bool contains(
const Input & other)
const;
96 kj::Promise<Result<std::pair<Tree, Input>>>
fetch(
ref<Store> store)
const;
99 std::optional<std::string>
ref,
100 std::optional<Hash> rev)
const;
102 void clone(
const Path & destDir)
const;
104 std::optional<Path> getSourcePath()
const;
112 std::string_view contents,
113 std::optional<std::string> commitMsg)
const;
115 std::string getName()
const;
120 std::string getType()
const;
121 std::optional<Hash> getNarHash()
const;
122 std::optional<std::string> getRef()
const;
123 std::optional<Hash> getRev()
const;
124 std::optional<uint64_t> getRevCount()
const;
125 std::optional<time_t> getLastModified()
const;
143 virtual std::optional<Input> inputFromURL(
const ParsedURL & url,
bool requireTree)
const = 0;
145 virtual std::optional<Input> inputFromAttrs(
const Attrs & attrs)
const = 0;
149 virtual bool hasAllInfo(
const Input & input)
const = 0;
151 virtual Input applyOverrides(
153 std::optional<std::string>
ref,
154 std::optional<Hash> rev)
const;
156 virtual void clone(
const Input & input,
const Path & destDir)
const;
158 virtual std::optional<Path> getSourcePath(
const Input & input)
const;
160 virtual void putFile(
163 std::string_view contents,
164 std::optional<std::string> commitMsg)
const;
166 virtual kj::Promise<Result<std::pair<StorePath, Input>>>
174 virtual bool isLockedByRev()
const {
return true; }
177 void emplaceURLQueryIntoAttrs(
180 const StringSet & numericParams,
181 const StringSet & booleanParams)
const
183 for (
auto &[name, value] : parsedURL.query) {
186 "URL '%s' must not override url via query param!",
187 parsedURL.to_string()
189 }
else if (numericParams.count(name) != 0) {
190 if (
auto n = string2Int<uint64_t>(value)) {
191 attrs.insert_or_assign(name, *n);
194 "URL '%s' has non-numeric parameter '%s'",
195 parsedURL.to_string(),
199 }
else if (booleanParams.count(name) != 0) {
202 attrs.emplace(name, value);
208void registerInputScheme(std::shared_ptr<InputScheme> && fetcher);
210void initLibFetchers();
216 std::string effectiveUrl;
217 std::optional<std::string> immutableUrl;
220kj::Promise<Result<DownloadFileResult>> downloadFile(
222 const std::string & url,
223 const std::string & name,
225 Headers headers = {},
232 std::optional<std::string> immutableUrl;
235kj::Promise<Result<DownloadTarballResult>> downloadTarball(
237 const std::string & url,
238 const std::string & name,
240 const Headers & headers = {});
Definition canon-path.hh:28
Definition store-api.hh:195
FileIngestionMethod
Definition content-address.hh:38
@ Flat
Definition content-address.hh:42
Definition fetchers.hh:213
Definition fetchers.hh:229
Definition fetchers.hh:23
std::string Path
Definition types.hh:28