Skip to content

Commit

Permalink
Support repairPath on most stores.
Browse files Browse the repository at this point in the history
More progress on issue NixOS#5729

The method trivially generalizes to be store-implementation-agnostic, in
fact.

However, we force it to continue to be unimplemented with `RemoteStore`
and `LegacySSHStore` because the implementation we'd get via the
generalization is probably not the one users expect. This keeps our
hands untied to do it right going forward.

For more about the tension between the scheduler logic being
store-type-agnostic and remote stores doing their own scheduling, see
issues NixOS#5025 and NixOS#5056.
  • Loading branch information
Ericson2314 committed Apr 13, 2023
1 parent ef0b483 commit 658a16b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libstore/build/entry-points.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Store::ensurePath(const StorePath & path)
}


void LocalStore::repairPath(const StorePath & path)
void Store::repairPath(const StorePath & path)
{
Worker worker(*this, *this);
GoalPtr goal = worker.makePathSubstitutionGoal(path, Repair);
Expand Down
11 changes: 11 additions & 0 deletions src/libstore/legacy-ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,17 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
void ensurePath(const StorePath & path) override
{ unsupported("ensurePath"); }

/**
* The default instance would schedule the work on the client side, but
* for consistency with `buildPaths` and `buildDerivation` it should happen
* on the remote side.
*
* We make this fail for now so we can add implement this properly later
* without it being a breaking change.
*/
void repairPath(const StorePath & path) override
{ unsupported("repairPath"); }

void computeFSClosure(const StorePathSet & paths,
StorePathSet & out, bool flipDirection = false,
bool includeOutputs = false, bool includeDerivers = false) override
Expand Down
2 changes: 0 additions & 2 deletions src/libstore/local-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ public:

void vacuumDB();

void repairPath(const StorePath & path) override;

void addSignatures(const StorePath & storePath, const StringSet & sigs) override;

/**
Expand Down
11 changes: 11 additions & 0 deletions src/libstore/remote-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ public:

bool verifyStore(bool checkContents, RepairFlag repair) override;

/**
* The default instance would schedule the work on the client side, but
* for consistency with `buildPaths` and `buildDerivation` it should happen
* on the remote side.
*
* We make this fail for now so we can add implement this properly later
* without it being a breaking change.
*/
void repairPath(const StorePath & path) override
{ unsupported("repairPath"); }

void addSignatures(const StorePath & storePath, const StringSet & sigs) override;

void queryMissing(const std::vector<DerivedPath> & targets,
Expand Down
3 changes: 1 addition & 2 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ public:
* Repair the contents of the given path by redownloading it using
* a substituter (if available).
*/
virtual void repairPath(const StorePath & path)
{ unsupported("repairPath"); }
virtual void repairPath(const StorePath & path);

/**
* Add signatures to the specified store path. The signatures are
Expand Down

0 comments on commit 658a16b

Please sign in to comment.