Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix/build: add --rebuild option #3761

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/nix/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using namespace nix;
struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
{
Path outLink = "result";
BuildMode buildMode = bmNormal;

CmdBuild()
{
Expand All @@ -26,6 +27,12 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
.description = "do not create a symlink to the build result",
.handler = {&outLink, Path("")},
});

addFlag({
.longName = "rebuild",
.description = "Rebuild an already built package locally and compare the result to the existing store-paths.",
.handler = {&buildMode, bmCheck},
});
}

std::string description() override
Expand Down Expand Up @@ -53,7 +60,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile

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

if (dryRun) return;

Expand Down
3 changes: 2 additions & 1 deletion src/nix/command.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "common-eval-args.hh"
#include "path.hh"
#include "flake/lockfile.hh"
#include "store-api.hh"

#include <optional>

Expand Down Expand Up @@ -185,7 +186,7 @@ static RegisterCommand registerCommand(const std::string & name)
}

Buildables build(ref<Store> store, Realise mode,
std::vector<std::shared_ptr<Installable>> installables);
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode = bmNormal);

std::set<StorePath> toStorePaths(ref<Store> store,
Realise mode, OperateOn operateOn,
Expand Down
4 changes: 2 additions & 2 deletions src/nix/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ std::shared_ptr<Installable> SourceExprCommand::parseInstallable(
}

Buildables build(ref<Store> store, Realise mode,
std::vector<std::shared_ptr<Installable>> installables)
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode)
{
if (mode == Realise::Nothing)
settings.readOnlyMode = true;
Expand All @@ -668,7 +668,7 @@ Buildables build(ref<Store> store, Realise mode,
if (mode == Realise::Nothing)
printMissing(store, pathsToBuild, lvlError);
else if (mode == Realise::Outputs)
store->buildPaths(pathsToBuild);
store->buildPaths(pathsToBuild, bMode);

return buildables;
}
Expand Down