forked from lix-project/lix
073e134de6
I should have done this to begin with. This will be nicer once more Store sub-interfaces exist too, to illustrate the pattern.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#include "command.hh"
|
|
#include "common-args.hh"
|
|
#include "shared.hh"
|
|
#include "store-api.hh"
|
|
#include "gc-store.hh"
|
|
|
|
using namespace nix;
|
|
|
|
struct CmdStoreDelete : StorePathsCommand
|
|
{
|
|
GCOptions options { .action = GCOptions::gcDeleteSpecific };
|
|
|
|
CmdStoreDelete()
|
|
{
|
|
addFlag({
|
|
.longName = "ignore-liveness",
|
|
.description = "Do not check whether the paths are reachable from a root.",
|
|
.handler = {&options.ignoreLiveness, true}
|
|
});
|
|
}
|
|
|
|
std::string description() override
|
|
{
|
|
return "delete paths from the Nix store";
|
|
}
|
|
|
|
std::string doc() override
|
|
{
|
|
return
|
|
#include "store-delete.md"
|
|
;
|
|
}
|
|
|
|
void run(ref<Store> store, std::vector<StorePath> && storePaths) override
|
|
{
|
|
auto & gcStore = GcStore::require(*store);
|
|
|
|
for (auto & path : storePaths)
|
|
options.pathsToDelete.insert(path);
|
|
|
|
GCResults results;
|
|
PrintFreed freed(true, results);
|
|
gcStore.collectGarbage(options, results);
|
|
}
|
|
};
|
|
|
|
static auto rCmdStoreDelete = registerCommand2<CmdStoreDelete>({"store", "delete"});
|