diff --git a/src/nix/meson.build b/src/nix/meson.build index 68c55495abc5..9968a93421d5 100644 --- a/src/nix/meson.build +++ b/src/nix/meson.build @@ -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', @@ -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', diff --git a/src/nix/add-root.cc b/src/nix/store-add-gc-root.cc similarity index 78% rename from src/nix/add-root.cc rename to src/nix/store-add-gc-root.cc index 541cf2559214..cecab256413f 100644 --- a/src/nix/add-root.cc +++ b/src/nix/store-add-gc-root.cc @@ -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 links; bool checkResults = true; - CmdAddRoot() + CmdAddGCRoot() { expectArgs({ .label = "indirect-roots", @@ -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" ; } @@ -53,7 +51,7 @@ 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); @@ -61,4 +59,4 @@ struct CmdAddRoot : StoreCommand } }; -static auto rCmdAddRoot = registerCommand("add-root"); +static auto rCmdAddGCRoot = registerCommand2({"store", "add-gc-root"}); diff --git a/src/nix/add-root.md b/src/nix/store-add-gc-root.md similarity index 85% rename from src/nix/add-root.md rename to src/nix/store-add-gc-root.md index 5a932a950a63..cd4841fb8a66 100644 --- a/src/nix/add-root.md +++ b/src/nix/store-add-gc-root.md @@ -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 ```