aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual/local.mk4
-rw-r--r--doc/manual/meson.build3
-rw-r--r--doc/manual/rl-next/nix-config-show.md7
-rw-r--r--doc/manual/src/SUMMARY.md2
-rw-r--r--doc/manual/src/command-ref/new-cli/nix3-config-show.md1
-rw-r--r--doc/manual/src/command-ref/new-cli/nix3-config.md1
-rw-r--r--doc/manual/src/command-ref/new-cli/nix3-show-config.md1
-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
-rw-r--r--tests/functional/config.sh12
-rw-r--r--tests/functional/experimental-features.sh8
12 files changed, 51 insertions, 18 deletions
diff --git a/doc/manual/local.mk b/doc/manual/local.mk
index 215609f79..50c67b8ae 100644
--- a/doc/manual/local.mk
+++ b/doc/manual/local.mk
@@ -29,7 +29,7 @@ man-pages += $(foreach subcommand, \
clean-files += $(d)/*.1 $(d)/*.5 $(d)/*.8
# Provide a dummy environment for nix, so that it will not access files outside the macOS sandbox.
-# Set cores to 0 because otherwise nix show-config resolves the cores based on the current machine
+# Set cores to 0 because otherwise nix config show resolves the cores based on the current machine
dummy-env = env -i \
HOME=/dummy \
NIX_CONF_DIR=/dummy \
@@ -89,7 +89,7 @@ doc/manual/generated/in/nix.json: $(doc_nix)
doc/manual/generated/in/conf-file.json: $(doc_nix)
@mkdir -p doc/manual/generated/in
- $(trace-gen) $(dummy-env) $(doc_nix) show-config --json --experimental-features nix-command > $@.tmp
+ $(trace-gen) $(dummy-env) $(doc_nix) config show --json --experimental-features nix-command > $@.tmp
@mv $@.tmp $@
doc/manual/generated/in/contributing/experimental-feature-descriptions.md: doc/manual/generated/in/xp-features.json $(d)/utils.nix $(d)/generate-xp-features.nix $(doc_nix)
diff --git a/doc/manual/meson.build b/doc/manual/meson.build
index cfb6be36f..e253a9bd8 100644
--- a/doc/manual/meson.build
+++ b/doc/manual/meson.build
@@ -197,6 +197,8 @@ endforeach
nix3_manpages = [
'nix3-build',
'nix3-bundle',
+ 'nix3-config',
+ 'nix3-config-show',
'nix3-copy',
'nix3-daemon',
'nix3-derivation-add',
@@ -258,7 +260,6 @@ nix3_manpages = [
'nix3-run',
'nix3-search',
'nix3-shell',
- 'nix3-show-config',
'nix3-store-add-file',
'nix3-store-add-path',
'nix3-store-cat',
diff --git a/doc/manual/rl-next/nix-config-show.md b/doc/manual/rl-next/nix-config-show.md
new file mode 100644
index 000000000..1e7545e73
--- /dev/null
+++ b/doc/manual/rl-next/nix-config-show.md
@@ -0,0 +1,7 @@
+---
+synopsis: rename 'nix show-config' to 'nix config show'
+issues: 7672
+prs: 9477
+---
+
+`nix show-config` was renamed to `nix config show` to be more consistent with the rest of the command-line interface.
diff --git a/doc/manual/src/SUMMARY.md b/doc/manual/src/SUMMARY.md
index 7747b9061..2437c0dc5 100644
--- a/doc/manual/src/SUMMARY.md
+++ b/doc/manual/src/SUMMARY.md
@@ -91,6 +91,8 @@
- [nix](command-ref/new-cli/nix.md)
- [nix build](command-ref/new-cli/nix3-build.md)
- [nix bundle](command-ref/new-cli/nix3-bundle.md)
+ - [nix config](command-ref/new-cli/nix3-config.md)
+ - [nix config show](command-ref/new-cli/nix3-config-show.md)
- [nix copy](command-ref/new-cli/nix3-copy.md)
- [nix daemon](command-ref/new-cli/nix3-daemon.md)
- [nix derivation](command-ref/new-cli/nix3-derivation.md)
diff --git a/doc/manual/src/command-ref/new-cli/nix3-config-show.md b/doc/manual/src/command-ref/new-cli/nix3-config-show.md
new file mode 100644
index 000000000..a39cd13e9
--- /dev/null
+++ b/doc/manual/src/command-ref/new-cli/nix3-config-show.md
@@ -0,0 +1 @@
+{{#include @generated@/command-ref/new-cli/nix3-config-show.md}}
diff --git a/doc/manual/src/command-ref/new-cli/nix3-config.md b/doc/manual/src/command-ref/new-cli/nix3-config.md
new file mode 100644
index 000000000..ba824c7bc
--- /dev/null
+++ b/doc/manual/src/command-ref/new-cli/nix3-config.md
@@ -0,0 +1 @@
+{{#include @generated@/command-ref/new-cli/nix3-config.md}}
diff --git a/doc/manual/src/command-ref/new-cli/nix3-show-config.md b/doc/manual/src/command-ref/new-cli/nix3-show-config.md
deleted file mode 100644
index 060fc065d..000000000
--- a/doc/manual/src/command-ref/new-cli/nix3-show-config.md
+++ /dev/null
@@ -1 +0,0 @@
-{{#include @generated@/command-ref/new-cli/nix3-show-config.md}}
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',
diff --git a/tests/functional/config.sh b/tests/functional/config.sh
index 723f575ed..46d606d3f 100644
--- a/tests/functional/config.sh
+++ b/tests/functional/config.sh
@@ -40,19 +40,19 @@ files=$(nix-build --verbose --version | grep "User config" | cut -d ':' -f2- | x
# Test that it's possible to load the config from a custom location
here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
export NIX_USER_CONF_FILES=$here/config/nix-with-substituters.conf
-var=$(nix show-config | grep '^substituters =' | cut -d '=' -f 2 | xargs)
+var=$(nix config show | grep '^substituters =' | cut -d '=' -f 2 | xargs)
[[ $var == https://example.com ]]
# Test that it's possible to load config from the environment
-prev=$(nix show-config | grep '^cores' | cut -d '=' -f 2 | xargs)
+prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command flakes"
-exp_cores=$(nix show-config | grep '^cores' | cut -d '=' -f 2 | xargs)
-exp_features=$(nix show-config | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
+exp_cores=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
+exp_features=$(nix config show | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
[[ $prev != $exp_cores ]]
[[ $exp_cores == "4242" ]]
[[ $exp_features == "flakes nix-command" ]]
# Test that it's possible to retrieve a single setting's value
-val=$(nix show-config | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
-val2=$(nix show-config warn-dirty)
+val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
+val2=$(nix config show warn-dirty)
[[ $val == $val2 ]]
diff --git a/tests/functional/experimental-features.sh b/tests/functional/experimental-features.sh
index 607bf0a8e..9ee4a53d4 100644
--- a/tests/functional/experimental-features.sh
+++ b/tests/functional/experimental-features.sh
@@ -31,7 +31,7 @@ source common.sh
NIX_CONFIG='
experimental-features = nix-command
accept-flake-config = true
-' nix show-config accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
+' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "false" $TEST_ROOT/stdout
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
@@ -39,7 +39,7 @@ grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature '
NIX_CONFIG='
accept-flake-config = true
experimental-features = nix-command
-' nix show-config accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
+' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "false" $TEST_ROOT/stdout
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
@@ -47,7 +47,7 @@ grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature '
NIX_CONFIG='
experimental-features = nix-command flakes
accept-flake-config = true
-' nix show-config accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
+' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "true" $TEST_ROOT/stdout
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
@@ -55,7 +55,7 @@ grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
NIX_CONFIG='
accept-flake-config = true
experimental-features = nix-command flakes
-' nix show-config accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
+' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "true" $TEST_ROOT/stdout
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr