aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/fetchers.hh
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-06-24 22:49:17 +0000
committerGerrit Code Review <gerrit@localhost>2024-06-24 22:49:17 +0000
commit3e151d4d77b5296b9da8c3ad209932d1dfa44c68 (patch)
treef5a047e858509a26594acb7cfd6b0f944509a2c4 /src/libfetchers/fetchers.hh
parent35eec921af1043fc6322edc0ad88c872d41623b8 (diff)
Revert "libfetchers: make attribute / URL query handling consistent"
This reverts commit 35eec921af1043fc6322edc0ad88c872d41623b8. Reason for revert: Regressed nix-eval-jobs, and it appears to be this change is buggy/missing a case. It just needs another pass. Code causing the problem in n-e-j, when invoked with `nix-eval-jobs --flake '.#hydraJobs'`: ``` n-e-j/tests/assets ยป ../../build/src/nix-eval-jobs --meta --workers 1 --flake .#hydraJobs warning: unknown setting 'trusted-users' warning: `--gc-roots-dir' not specified error: unsupported Git input attribute 'dir' error: worker error: error: unsupported Git input attribute 'dir' ``` ``` nix::Value *vRoot = [&]() { if (args.flake) { auto [flakeRef, fragment, outputSpec] = nix::parseFlakeRefWithFragmentAndExtendedOutputsSpec( args.releaseExpr, nix::absPath(".")); nix::InstallableFlake flake{ {}, state, std::move(flakeRef), fragment, outputSpec, {}, {}, args.lockFlags}; return flake.toValue(*state).first; } else { return releaseExprTopLevelValue(*state, autoArgs, args); } }(); ``` Inspecting the program behaviour reveals that `dir` was in fact set in the URL going into the fetcher. This is in turn because unlike in the case changed in this commit, it was not erased before handing it to libfetchers, which is probably just a mistake. ``` (rr) up 3 0x00007ffff60262ae in nix::fetchers::Input::fromURL (url=..., requireTree=requireTree@entry=true) at src/libfetchers/fetchers.cc:39 warning: Source file is more recent than executable. 39 auto res = inputScheme->inputFromURL(url, requireTree); (rr) p url $1 = (const nix::ParsedURL &) @0x7fffdc874190: {url = "git+file:///home/jade/lix/nix-eval-jobs", base = "git+file:///home/jade/lix/nix-eval-jobs", scheme = "git+file", authority = std::optional<std::string> = {[contained value] = ""}, path = "/home/jade/lix/nix-eval-jobs", query = std::map with 1 element = {["dir"] = "tests/assets"}, fragment = ""} (rr) up 4 0x00007ffff789d904 in nix::parseFlakeRefWithFragment (url=".#hydraJobs", baseDir=std::optional<std::string> = {...}, allowMissing=allowMissing@entry=false, isFlake=isFlake@entry=true) at src/libexpr/flake/flakeref.cc:179 warning: Source file is more recent than executable. 179 FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")), (rr) p parsedURL $2 = {url = "git+file:///home/jade/lix/nix-eval-jobs", base = "git+file:///home/jade/lix/nix-eval-jobs", scheme = "git+file", authority = std::optional<std::string> = {[contained value] = ""}, path = "/home/jade/lix/nix-eval-jobs", query = std::map with 1 element = { ["dir"] = "tests/assets"}, fragment = ""} (rr) list 174 175 if (pathExists(flakeRoot + "/.git/shallow")) 176 parsedURL.query.insert_or_assign("shallow", "1"); 177 178 return std::make_pair( 179 FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")), 180 fragment); 181 } ``` Change-Id: Ib55a882eaeb3e59228857761dc1e3b2e366b0f5e
Diffstat (limited to 'src/libfetchers/fetchers.hh')
-rw-r--r--src/libfetchers/fetchers.hh31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh
index 40f2b6294..2bb4248be 100644
--- a/src/libfetchers/fetchers.hh
+++ b/src/libfetchers/fetchers.hh
@@ -159,37 +159,6 @@ struct InputScheme
std::optional<std::string> commitMsg) const;
virtual std::pair<StorePath, Input> fetch(ref<Store> store, const Input & input) = 0;
-
-protected:
- void emplaceURLQueryIntoAttrs(
- const ParsedURL & parsedURL,
- Attrs & attrs,
- const StringSet & numericParams,
- const StringSet & booleanParams) const
- {
- for (auto &[name, value] : parsedURL.query) {
- if (name == "url") {
- throw BadURL(
- "URL '%s' must not override url via query param!",
- parsedURL.to_string()
- );
- } else if (numericParams.count(name) != 0) {
- if (auto n = string2Int<uint64_t>(value)) {
- attrs.insert_or_assign(name, *n);
- } else {
- throw BadURL(
- "URL '%s' has non-numeric parameter '%s'",
- parsedURL.to_string(),
- name
- );
- }
- } else if (booleanParams.count(name) != 0) {
- attrs.emplace(name, Explicit<bool> { value == "1" });
- } else {
- attrs.emplace(name, value);
- }
- }
- }
};
void registerInputScheme(std::shared_ptr<InputScheme> && fetcher);