aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2024-08-18 21:50:54 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2024-08-19 19:57:12 +0000
commit040e7832323ca6ed59bd58620bca35a496f977b1 (patch)
treebd3868bc5a1110fc04d484ee327aaed7ddcfa3f8 /src/libexpr
parente727dbc3a3d59d7742a24a2b394b63a04ecb4d24 (diff)
flake: don't refetch unmodified inputs by recursive follows
Closes #460 I managed to trigger the issue by having the following inputs (shortened): authentik-nix.url = "github:nix-community/authentik-nix"; authentik-nix.inputs.poetry2nix.inputs.nixpkgs.follows = "nixpkgs"; When evaluating this using nix-eval-jobs --flake .#hydraJobs I got the following error: error: cannot update unlocked flake input 'authentik-nix/poetry2nix' in pure mode The issue we have here is that `authentik-nix/poetry2nix` was written into the `overrideMap` which caused Nix to assume it's a new input and tried to refetch it (#460) or errored out in pure mode (nix-eval-jobs / Hydra). The testcase unfortunately only involves checking for the output log and makes sure that something *is* logged on the first fetch so that the test doesn't rot when the logging changes since I didn't manage to trigger the error above with the reproducer from #460. In fact, I only managed to trigger the `cannot update unlocked flake input` error in this context with `nix-eval-jobs`. Change-Id: Ifd00091eec9a0067ed4bb3e5765a15d027328807
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flake.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 7f0e5b1e9..ab13ba3be 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -342,8 +342,21 @@ static void updateOverrides(std::map<InputPath, FlakeInput> & overrideMap, const
for (auto & [id, input] : overrides) {
auto inputPath(inputPathPrefix);
inputPath.push_back(id);
- // Do not override existing assignment from outer flake
- overrideMap.insert({inputPath, input});
+
+ /* Given
+ *
+ * { inputs.hydra.inputs.nix-eval-jobs.inputs.lix.follows = "lix"; }
+ *
+ * then `nix-eval-jobs` doesn't have an override.
+ * It's neither replaced using follows nor by a different
+ * URL. Thus no need to add it to overrides and thus re-fetch
+ * it.
+ */
+ if (input.ref || input.follows) {
+ // Do not override existing assignment from outer flake
+ overrideMap.insert({inputPath, input});
+ }
+
updateOverrides(overrideMap, input.overrides, inputPath);
}
}