From 11b5cf95615ffb2a2475ac444f4fe103e471748f Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Tue, 18 Oct 2022 15:09:17 -0700 Subject: [PATCH 1/2] fix manual defaults --- src/nix/main.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/nix/main.cc b/src/nix/main.cc index d78312944..f008ea2b7 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -369,6 +369,13 @@ void mainWrapped(int argc, char * * argv) && args.command->first != "upgrade-nix") settings.requireExperimentalFeature(Xp::NixCommand); + if (args.command->first == "show-config") { + // show-config must run before any settings are modified so that it outputs the defaults + args.command->second->prepare(); + args.command->second->run(); + return; + } + if (args.useNet && !haveInternet()) { warn("you don't have Internet access; disabling some network-dependent features"); args.useNet = false; From b44df1370187bea82814a2da50a6ded54fca65f2 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Thu, 20 Oct 2022 12:05:04 -0700 Subject: [PATCH 2/2] manual: update options generation code to use default values --- doc/manual/generate-options.nix | 10 +++++----- src/nix/main.cc | 7 ------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/manual/generate-options.nix b/doc/manual/generate-options.nix index 2d586fa1b..680b709c8 100644 --- a/doc/manual/generate-options.nix +++ b/doc/manual/generate-options.nix @@ -11,16 +11,16 @@ concatStrings (map + concatStrings (map (s: " ${s}\n") (splitLines option.description)) + "\n\n" + (if option.documentDefault then " **Default:** " + ( - if option.value == "" || option.value == [] + if option.defaultValue == "" || option.defaultValue == [] then "*empty*" - else if isBool option.value - then (if option.value then "`true`" else "`false`") + else if isBool option.defaultValue + then (if option.defaultValue then "`true`" else "`false`") else # n.b. a StringMap value type is specified as a string, but # this shows the value type. The empty stringmap is "null" in # JSON, but that converts to "{ }" here. - (if isAttrs option.value then "`\"\"`" - else "`" + toString option.value + "`")) + "\n\n" + (if isAttrs option.defaultValue then "`\"\"`" + else "`" + toString option.defaultValue + "`")) + "\n\n" else " **Default:** *machine-specific*\n") + (if option.aliases != [] then " **Deprecated alias:** " + (concatStringsSep ", " (map (s: "`${s}`") option.aliases)) + "\n\n" diff --git a/src/nix/main.cc b/src/nix/main.cc index f008ea2b7..d78312944 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -369,13 +369,6 @@ void mainWrapped(int argc, char * * argv) && args.command->first != "upgrade-nix") settings.requireExperimentalFeature(Xp::NixCommand); - if (args.command->first == "show-config") { - // show-config must run before any settings are modified so that it outputs the defaults - args.command->second->prepare(); - args.command->second->run(); - return; - } - if (args.useNet && !haveInternet()) { warn("you don't have Internet access; disabling some network-dependent features"); args.useNet = false;