From 54525682df707742e58311c32e9c9cb18de1e31f Mon Sep 17 00:00:00 2001 From: Georges Dubus Date: Fri, 3 Jul 2020 14:21:31 +0200 Subject: [PATCH] Don't use read-only mode for nix build --dry-run 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 #1795 --- src/libcmd/installables.cc | 2 +- src/nix/build.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 4739dc974..e10f39758 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -716,7 +716,7 @@ Buildables build(ref 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); diff --git a/src/nix/build.cc b/src/nix/build.cc index 724ce9d79..a40f87f19 100644 --- a/src/nix/build.cc +++ b/src/nix/build.cc @@ -52,7 +52,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile void run(ref 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;