diff options
author | Théophane Hufschmitt <theophane@hufschmitt.net> | 2022-03-17 11:34:31 +0100 |
---|---|---|
committer | Théophane Hufschmitt <theophane@hufschmitt.net> | 2022-03-17 11:55:19 +0100 |
commit | 3fc4c612fbde332d66b78dcc5b17b7d0d5235484 (patch) | |
tree | b8de5af62186ad944edd91a183354b0984f84087 /src/nix | |
parent | fe1ad9613561ea78b6d97cf82c03d2dd77e43f69 (diff) |
Fix `nix build --dry-run` with CA derivations
Don’t try and assume that we know the output paths when we’ve just built
with `--dry-run`. Instead make `--dry-run` follow a different code path
that won’t assume the knowledge of the output paths at all.
Fix #6275
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/build.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc index 680db1c60..840c7ca38 100644 --- a/src/nix/build.cc +++ b/src/nix/build.cc @@ -52,15 +52,26 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile void run(ref<Store> store) override { + if (dryRun) { + std::vector<DerivedPath> pathsToBuild; + + for (auto & i : installables) { + auto b = i->toDerivedPaths(); + pathsToBuild.insert(pathsToBuild.end(), b.begin(), b.end()); + } + printMissing(store, pathsToBuild, lvlError); + if (json) + logger->cout("%s", derivedPathsToJSON(pathsToBuild, store).dump()); + return; + } + auto buildables = Installable::build( getEvalStore(), store, - dryRun ? Realise::Derivation : Realise::Outputs, + Realise::Outputs, installables, buildMode); if (json) logger->cout("%s", derivedPathsWithHintsToJSON(buildables, store).dump()); - if (dryRun) return; - if (outLink != "") if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) for (const auto & [_i, buildable] : enumerate(buildables)) { |