infrastructure/patches/lix/02-fetchGit-locked.patch
Tom Hubrecht 10f5322016
All checks were successful
Check meta / check_dns (pull_request) Successful in 18s
Check meta / check_meta (pull_request) Successful in 18s
Check workflows / check_workflows (pull_request) Successful in 19s
Build all the nodes / netcore00 (pull_request) Successful in 28s
Build all the nodes / netcore01 (pull_request) Successful in 28s
Build all the nodes / netcore02 (pull_request) Successful in 28s
Build all the nodes / netaccess01 (pull_request) Successful in 28s
Run pre-commit on all files / pre-commit (pull_request) Successful in 34s
Build all the nodes / ap01 (pull_request) Successful in 43s
Build all the nodes / bridge01 (pull_request) Successful in 57s
Build all the nodes / hypervisor01 (pull_request) Successful in 1m2s
Build all the nodes / cof02 (pull_request) Successful in 1m8s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m9s
Build all the nodes / geo01 (pull_request) Successful in 1m10s
Build all the nodes / build01 (pull_request) Successful in 1m10s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m9s
Build all the nodes / lab-router01 (pull_request) Successful in 1m8s
Build all the nodes / iso (pull_request) Successful in 1m10s
Build all the nodes / geo02 (pull_request) Successful in 1m15s
Build all the nodes / compute01 (pull_request) Successful in 1m30s
Build all the nodes / rescue01 (pull_request) Successful in 1m13s
Build all the nodes / tower01 (pull_request) Successful in 1m6s
Build the shell / build-shell (pull_request) Successful in 42s
Build all the nodes / web02 (pull_request) Successful in 1m11s
Build all the nodes / vault01 (pull_request) Successful in 1m16s
Build all the nodes / web03 (pull_request) Successful in 1m6s
Build all the nodes / krz01 (pull_request) Successful in 1m51s
Build all the nodes / web01 (pull_request) Successful in 1m23s
Build all the nodes / storage01 (pull_request) Successful in 1m33s
Build all the nodes / netcore02 (push) Successful in 27s
Build all the nodes / netaccess01 (push) Successful in 30s
Build all the nodes / netcore01 (push) Successful in 30s
Build all the nodes / netcore00 (push) Successful in 30s
Run pre-commit on all files / pre-commit (push) Successful in 37s
Build all the nodes / ap01 (push) Successful in 46s
Build the shell / build-shell (push) Successful in 35s
Build all the nodes / geo02 (push) Successful in 1m6s
Build all the nodes / hypervisor02 (push) Successful in 1m12s
Build all the nodes / bridge01 (push) Successful in 1m15s
Build all the nodes / hypervisor01 (push) Successful in 1m14s
Build all the nodes / geo01 (push) Successful in 1m20s
Build all the nodes / hypervisor03 (push) Successful in 1m24s
Build all the nodes / cof02 (push) Successful in 1m26s
Build all the nodes / build01 (push) Successful in 1m30s
Build all the nodes / vault01 (push) Successful in 1m29s
Build all the nodes / tower01 (push) Successful in 1m30s
Build all the nodes / lab-router01 (push) Successful in 1m32s
Build all the nodes / iso (push) Successful in 1m38s
Build all the nodes / rescue01 (push) Successful in 1m41s
Build all the nodes / web01 (push) Successful in 1m47s
Build all the nodes / web03 (push) Successful in 1m20s
Build all the nodes / web02 (push) Successful in 1m22s
Build all the nodes / compute01 (push) Successful in 1m52s
Build all the nodes / storage01 (push) Successful in 1m52s
Build all the nodes / krz01 (push) Successful in 1m53s
fix(lix): Make fetchGit use the narHash attribute
2025-05-11 15:54:41 +02:00

86 lines
3.5 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git i/lix/libexpr/primops/fetchTree.cc w/lix/libexpr/primops/fetchTree.cc
index 93b08ecc9..6d04ce24b 100644
--- i/lix/libexpr/primops/fetchTree.cc
+++ w/lix/libexpr/primops/fetchTree.cc
@@ -168,6 +168,11 @@ static void fetchTree(
"attribute 'name' isnt supported in call to 'fetchTree'"
).atPos(pos).debugThrow();
+ // HACK: When using `fetchGit`, locking with only the hash should happen
+ // as we don't care about flake hallucinations about `lastModified`
+ if (type == "git" && attrs.contains("narHash"))
+ attrs["type"] = "git-locked";
+
input = fetchers::Input::fromAttrs(std::move(attrs));
} else {
auto url = state.coerceToString(pos, *args[0], context,
diff --git i/lix/libfetchers/builtin-fetchers.hh w/lix/libfetchers/builtin-fetchers.hh
index d3be7f7f2..d1389b8ba 100644
--- i/lix/libfetchers/builtin-fetchers.hh
+++ w/lix/libfetchers/builtin-fetchers.hh
@@ -10,6 +10,7 @@ std::unique_ptr<InputScheme> makePathInputScheme();
std::unique_ptr<InputScheme> makeFileInputScheme();
std::unique_ptr<InputScheme> makeTarballInputScheme();
std::unique_ptr<InputScheme> makeGitInputScheme();
+std::unique_ptr<InputScheme> makeGitLockedInputScheme();
std::unique_ptr<InputScheme> makeMercurialInputScheme();
std::unique_ptr<InputScheme> makeGitHubInputScheme();
std::unique_ptr<InputScheme> makeGitLabInputScheme();
diff --git i/lix/libfetchers/fetchers.cc w/lix/libfetchers/fetchers.cc
index 0dc9f5e0c..91cd9332d 100644
--- i/lix/libfetchers/fetchers.cc
+++ w/lix/libfetchers/fetchers.cc
@@ -22,6 +22,7 @@ void initLibFetchers()
registerInputScheme(makeTarballInputScheme());
registerInputScheme(makeFileInputScheme());
registerInputScheme(makeGitInputScheme());
+ registerInputScheme(makeGitLockedInputScheme());
registerInputScheme(makeMercurialInputScheme());
registerInputScheme(makeGitHubInputScheme());
registerInputScheme(makeGitLabInputScheme());
diff --git i/lix/libfetchers/git.cc w/lix/libfetchers/git.cc
index 21fa1904d..f9573eacd 100644
--- i/lix/libfetchers/git.cc
+++ w/lix/libfetchers/git.cc
@@ -812,4 +812,40 @@ std::unique_ptr<InputScheme> makeGitInputScheme()
return std::make_unique<GitInputScheme>();
}
+struct GitLockedInputScheme : GitInputScheme {
+
+ std::optional<Input> inputFromAttrs(const Attrs & attrs) const override
+ {
+ if (maybeGetStrAttr(attrs, "type") != "git-locked") return {};
+
+ for (auto & [name, value] : attrs)
+ if (name != "type" && name != "url" && name != "ref" && name != "rev" && name != "shallow" && name != "submodules" && name != "lastModified" && name != "revCount" && name != "narHash" && name != "allRefs" && name != "name" && name != "dirtyRev" && name != "dirtyShortRev")
+ throw Error("unsupported Git input attribute '%s'", name);
+
+ parseURL(getStrAttr(attrs, "url"));
+ maybeGetBoolAttr(attrs, "shallow");
+ maybeGetBoolAttr(attrs, "submodules");
+ maybeGetBoolAttr(attrs, "allRefs");
+
+ if (auto ref = maybeGetStrAttr(attrs, "ref")) {
+ if (std::regex_search(*ref, badGitRefRegex))
+ throw BadURL("invalid Git branch/tag name '%s'", *ref);
+ }
+
+ Input input;
+ input.attrs = attrs;
+ return input;
+ }
+
+ bool hasAllInfo(const Input & input) const override {
+ return true;
+ }
+
+};
+
+std::unique_ptr<InputScheme> makeGitLockedInputScheme()
+{
+ return std::make_unique<GitLockedInputScheme>();
+}
+
}