aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2023-11-27 19:41:30 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2024-05-03 16:26:16 +0200
commit8458d98b274910e35baceda77f3e573817ed9f41 (patch)
tree27fc81d23320a98c5a532a5ccc2ffbbdca2de960 /src/nix
parent6f0636a7ed40bb1254b294eedac4f7ca04d387d6 (diff)
Rename `nix show-config` to `nix config show`
Part of #7672 My main motivation is to be able to use `nix.checkConfig`[1]. This doesn't work with Lix currently since the module uses `nix show-config` if the Nix version is <2.20pre and `nix config show` otherwise. I think this is the only instance where nixpkgs checks for which Nix commands exist that affects us now, so I figured we could just perform the rename here as well[2] and still provide the current version number[3]. I don't have a strong opinion on whether to deprecate `nix show-config`, the warning is added there automatically. (cherry picked from commit f300e11b056dea414d7d77bbc6e5a7dc5d9ddd41) [1] https://nixos.org/manual/nixos/stable/options.html#opt-nix.checkConfig [2] I should add that I don't use the "official" ways of installing Lix because using the flake directly and callPackaging it seemed to fit better into my workflow: I already have a little mess to make sure Hydra from the flake uses the correct pkgs.nix and I didn't want to complicate it further while keeping a single package-set I can build in CI. Don't get me wrong, I think such a module for a quick-start is very important, just giving context on why I bother in the first place :) [3] When we go public, I think it's worth considering to add support in nixpkgs itself for Lix. Change-Id: I47b4239b05cbeda3c370d2fa56ea768b768768ac
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/config.cc (renamed from src/nix/show-config.cc)27
-rw-r--r--src/nix/main.cc1
-rw-r--r--src/nix/meson.build2
3 files changed, 26 insertions, 4 deletions
diff --git a/src/nix/show-config.cc b/src/nix/config.cc
index 3530584f9..5b280d11d 100644
--- a/src/nix/show-config.cc
+++ b/src/nix/config.cc
@@ -7,11 +7,31 @@
using namespace nix;
-struct CmdShowConfig : Command, MixJSON
+struct CmdConfig : virtual NixMultiCommand
+{
+ CmdConfig() : MultiCommand(RegisterCommand::getCommandsFor({"config"}))
+ { }
+
+ std::string description() override
+ {
+ return "manipulate the Nix configuration";
+ }
+
+ Category category() override { return catUtility; }
+
+ void run() override
+ {
+ if (!command)
+ throw UsageError("'nix config' requires a sub-command.");
+ command->second->run();
+ }
+};
+
+struct CmdConfigShow : Command, MixJSON
{
std::optional<std::string> name;
- CmdShowConfig() {
+ CmdConfigShow() {
expectArgs({
.label = {"name"},
.optional = true,
@@ -56,4 +76,5 @@ struct CmdShowConfig : Command, MixJSON
}
};
-static auto rShowConfig = registerCommand<CmdShowConfig>("show-config");
+static auto rCmdConfig = registerCommand<CmdConfig>("config");
+static auto rShowConfig = registerCommand2<CmdConfigShow>({"config", "show"});
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 6bc46eba3..64755d445 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -151,6 +151,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
{"ping-store", {"store", "ping"}},
{"sign-paths", {"store", "sign"}},
{"show-derivation", {"derivation", "show"}},
+ {"show-config", {"config", "show"}},
{"to-base16", {"hash", "to-base16"}},
{"to-base32", {"hash", "to-base32"}},
{"to-base64", {"hash", "to-base64"}},
diff --git a/src/nix/meson.build b/src/nix/meson.build
index cb8f73174..e41399b5d 100644
--- a/src/nix/meson.build
+++ b/src/nix/meson.build
@@ -59,7 +59,7 @@ nix_sources = files(
'repl.cc',
'run.cc',
'search.cc',
- 'show-config.cc',
+ 'config.cc',
'sigs.cc',
'store-copy-log.cc',
'store-delete.cc',