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 store repair --keep-going #11877

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion src/libstore/build/entry-points.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void Store::repairPath(const StorePath & path)
}, bmRepair));
worker.run(goals);
} else
throw Error(worker.failingExitStatus(), "cannot repair path '%s'", printStorePath(path));
throw RepairFailure(worker.failingExitStatus(), "cannot repair path '%s'", printStorePath(path));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ MakeError(InvalidPath, Error);
MakeError(Unsupported, Error);
MakeError(SubstituteGone, Error);
MakeError(SubstituterDisabled, Error);
MakeError(RepairFailure, Error);

MakeError(InvalidStoreReference, Error);

Expand Down
26 changes: 25 additions & 1 deletion src/nix/store-repair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,32 @@ struct CmdStoreRepair : StorePathsCommand

void run(ref<Store> store, StorePaths && storePaths) override
{
size_t errors = 0;

// Remove duplicates.
StorePathSet storePathsSet;
for (auto & path : storePaths)
store->repairPath(path);
storePathsSet.insert(path);

for (auto & path : storePathsSet) {
Comment on lines +24 to +29
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be bottom-up, ie dependencies first. That way when we do a "substitution fallback" build, we don't use broken inputs.

try {
store->repairPath(path);
} catch (Error & e) {
// RepairFailure already has the path in the error message, so we omit the redundant trace.
if (!dynamic_cast<RepairFailure *>(&e))
e.addTrace({}, "while repairing path '%s'", store->printStorePath(path));

if (settings.keepGoing) {
errors++;
ignoreExceptionExceptInterrupt();
}
else
throw;
}
}

if (errors)
throw Error("could not repair %d store paths", errors);
}
};

Expand Down
Loading