Skip to content

Commit

Permalink
Rename to 'nix store add-gc-root'
Browse files Browse the repository at this point in the history
  • Loading branch information
layus committed Sep 17, 2024
1 parent 9465b19 commit 3855ac9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/nix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ subdir('build-utils-meson/diagnostics')
subdir('build-utils-meson/generate-header')

nix_sources = [config_h] + files(
'add-root.cc',
'add-to-store.cc',
'app.cc',
'self-exe.cc',
Expand Down Expand Up @@ -106,6 +105,7 @@ nix_sources = [config_h] + files(
'run.cc',
'search.cc',
'sigs.cc',
'store-add-gc-root.cc',
'store-copy-log.cc',
'store-delete.cc',
'store-gc.cc',
Expand Down
14 changes: 6 additions & 8 deletions src/nix/add-root.cc → src/nix/store-add-gc-root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
#include "store-cast.hh"
#include "indirect-root-store.hh"
#include "common-args.hh"
#include "strings.hh"
#include "installable-derived-path.hh"

using namespace nix;

struct CmdAddRoot : StoreCommand
struct CmdAddGCRoot : StoreCommand
{
std::vector<std::string> links;
bool checkResults = true;

CmdAddRoot()
CmdAddGCRoot()
{
expectArgs({
.label = "indirect-roots",
Expand All @@ -25,13 +23,13 @@ struct CmdAddRoot : StoreCommand

std::string description() override
{
return "Add indirect gc-roots through the symlink arguments";
return "Add indirect gc roots through the symlink arguments";
}

std::string doc() override
{
return
#include "add-root.md"
#include "store-add-gc-root.md"
;
}

Expand All @@ -53,12 +51,12 @@ struct CmdAddRoot : StoreCommand
if (checkResults) {
auto path = indirectRootStore.followLinksToStorePath(indirectPath);
indirectRootStore.addTempRoot(path);
// TODO: ensure the path is safe from concurrent GC of fail.
// TODO: ensure `path` is safe from concurrent GC or fail.
}

indirectRootStore.addIndirectRoot(indirectPath);
}
}
};

static auto rCmdAddRoot = registerCommand<CmdAddRoot>("add-root");
static auto rCmdAddGCRoot = registerCommand2<CmdAddGCRoot>({"store", "add-gc-root"});
5 changes: 2 additions & 3 deletions src/nix/add-root.md → src/nix/store-add-gc-root.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ R""(
# Examples

```console
$ readlink foo
/nix/store/xxx
$ nix add-root foo
$ ln -s /nix/store/xxx foo
$ nix store add-gc-root foo
$ nix-store -q --roots /nix/store/xxx
.../foo -> /nix/store/xxx
```
Expand Down

0 comments on commit 3855ac9

Please sign in to comment.