2021-01-11 18:46:17 +00:00
|
|
|
#include "command.hh"
|
|
|
|
#include "common-args.hh"
|
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
2022-03-01 18:31:36 +00:00
|
|
|
#include "gc-store.hh"
|
2021-01-11 18:46:17 +00:00
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
|
|
|
struct CmdStoreDelete : StorePathsCommand
|
|
|
|
{
|
|
|
|
GCOptions options { .action = GCOptions::gcDeleteSpecific };
|
|
|
|
|
|
|
|
CmdStoreDelete()
|
|
|
|
{
|
|
|
|
addFlag({
|
|
|
|
.longName = "ignore-liveness",
|
2021-01-13 13:18:04 +00:00
|
|
|
.description = "Do not check whether the paths are reachable from a root.",
|
2021-01-11 18:46:17 +00:00
|
|
|
.handler = {&options.ignoreLiveness, true}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string description() override
|
|
|
|
{
|
|
|
|
return "delete paths from the Nix store";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string doc() override
|
|
|
|
{
|
|
|
|
return
|
|
|
|
#include "store-delete.md"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-09-27 08:53:09 +00:00
|
|
|
void run(ref<Store> store, std::vector<StorePath> && storePaths) override
|
2021-01-11 18:46:17 +00:00
|
|
|
{
|
2022-03-08 17:45:19 +00:00
|
|
|
auto & gcStore = GcStore::require(*store);
|
2022-03-01 18:31:36 +00:00
|
|
|
|
2021-01-11 18:46:17 +00:00
|
|
|
for (auto & path : storePaths)
|
|
|
|
options.pathsToDelete.insert(path);
|
|
|
|
|
|
|
|
GCResults results;
|
|
|
|
PrintFreed freed(true, results);
|
2022-03-01 18:31:36 +00:00
|
|
|
gcStore.collectGarbage(options, results);
|
2021-01-11 18:46:17 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static auto rCmdStoreDelete = registerCommand2<CmdStoreDelete>({"store", "delete"});
|