From d678b071d69569786db4a4cc8110ee0cd4496e2f Mon Sep 17 00:00:00 2001 From: Oleksandr Knyshuk Date: Thu, 17 Jul 2025 17:26:56 +0200 Subject: [PATCH] Make nix help shell work by handling aliases properly Previously, `nix help shell` failed with "Nix has no subcommand 'shell'" despite `nix shell --help` working correctly. This happened because the `shell` command is actually an alias for `env shell`, and the help system wasn't resolving aliases when looking up documentation. This patch modifies the `showHelp` function to check for and resolve aliases before generating the manpage name, ensuring that shorthand commands like `shell` get proper help documentation. Closes: #13431 --- src/nix/main.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/nix/main.cc b/src/nix/main.cc index 6144f746f..502e04e60 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -212,6 +212,14 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs lowdown. */ static void showHelp(std::vector subcommand, NixArgs & toplevel) { + // Check for aliases if subcommand has exactly one element + if (subcommand.size() == 1) { + auto alias = toplevel.aliases.find(subcommand[0]); + if (alias != toplevel.aliases.end()) { + subcommand = alias->second.replacement; + } + } + auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand)); evalSettings.restrictEval = false;