Move store docs to 'nix help-stores'

Why not 'nix help stores'? Well, 'nix help <arg>' already means 'show
help on the "arg" subcommand'.
This commit is contained in:
Eelco Dolstra 2023-03-21 14:37:09 +01:00
parent 3fc4659d22
commit 233b063b08
6 changed files with 44 additions and 21 deletions

View file

@ -97,7 +97,10 @@ public:
Path nixDaemonSocketFile;
Setting<std::string> storeUri{this, getEnv("NIX_REMOTE").value_or("auto"), "store",
"The default Nix store to use."};
R"(
The URL of the Nix store to use. See [`nix help-stores`](@docroot@/command-ref/new-cli/nix3-help-stores.md)
for supported store types and settings.
)"};
Setting<bool> keepFailed{this, false, "keep-failed",
"Whether to keep temporary directories of failed builds."};

7
src/nix/help-stores.md Normal file
View file

@ -0,0 +1,7 @@
R"(
Nix supports different types of stores. These are described below.
@stores@
)"

View file

@ -223,6 +223,14 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
std::cout << renderMarkdownToTerminal(markdown) << "\n";
}
static NixArgs & getNixArgs(Command & cmd)
{
assert(cmd.parent);
MultiCommand * toplevel = cmd.parent;
while (toplevel->parent) toplevel = toplevel->parent;
return dynamic_cast<NixArgs &>(*toplevel);
}
struct CmdHelp : Command
{
std::vector<std::string> subcommand;
@ -252,12 +260,34 @@ struct CmdHelp : Command
assert(parent);
MultiCommand * toplevel = parent;
while (toplevel->parent) toplevel = toplevel->parent;
showHelp(subcommand, dynamic_cast<NixArgs &>(*toplevel));
showHelp(subcommand, getNixArgs(*this));
}
};
static auto rCmdHelp = registerCommand<CmdHelp>("help");
struct CmdHelpStores : Command
{
std::string description() override
{
return "show help about store types and their settings";
}
std::string doc() override
{
return
#include "help-stores.md"
;
}
void run() override
{
showHelp({"help-stores"}, getNixArgs(*this));
}
};
static auto rCmdHelpStores = registerCommand<CmdHelpStores>("help-stores");
void mainWrapped(int argc, char * * argv)
{
savedArgv = argv;

View file

@ -220,8 +220,7 @@ operate are determined as follows:
# Nix stores
Most `nix` subcommands operate on a *Nix store*.
TODO: list store types, options
Most `nix` subcommands operate on a *Nix store*. These are documented
in [`nix help-stores`](./nix3-help-stores.md).
)""

View file

@ -12,13 +12,6 @@ struct CmdStore : virtual NixMultiCommand
return "manipulate a Nix store";
}
std::string doc() override
{
return
#include "store.md"
;
}
Category category() override { return catUtility; }
void run() override

View file

@ -1,9 +0,0 @@
R"(
# Store types
Nix supports different types of stores. These are listed below.
@stores@
)"