Skip to content

Commit

Permalink
Don't use read-only mode for nix build --dry-run
Browse files Browse the repository at this point in the history
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
  • Loading branch information
madjar committed Feb 24, 2021
1 parent 199081a commit 5452568
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Buildables build(ref<Store> store, Realise mode,
}
}

if (mode == Realise::Nothing)
if (mode == Realise::Nothing || mode == Realise::Derivation)
printMissing(store, pathsToBuild, lvlError);
else if (mode == Realise::Outputs)
store->buildPaths(pathsToBuild, bMode);
Expand Down
2 changes: 1 addition & 1 deletion src/nix/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile

void run(ref<Store> store) override
{
auto buildables = build(store, dryRun ? Realise::Nothing : Realise::Outputs, installables, buildMode);
auto buildables = build(store, dryRun ? Realise::Derivation : Realise::Outputs, installables, buildMode);

if (dryRun) return;

Expand Down

0 comments on commit 5452568

Please sign in to comment.