about summary refs log tree commit diff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-06-07T14·49+0200
committerEelco Dolstra <edolstra@gmail.com>2017-06-07T14·49+0200
commitaa952d5f0bc623a1584f2d589209f586e594c75f (patch)
tree685780bc5155600f5f27f04c09302e2644236cad /src/nix
parentb8283773bd64d7da6859ed520ee19867742a03ba (diff)
nix: Add --help-config flag
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/main.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc
index f83843415e3b..ea6838cd76c9 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -21,10 +21,30 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
             throw Exit();
         });
 
+        mkFlag(0, "help-config", "show configuration options", [=]() {
+            std::cout << "The following configuration options are available:\n\n";
+            Table2 tbl;
+            for (const auto & s : settings._getSettings())
+                if (!s.second.isAlias)
+                    tbl.emplace_back(s.first, s.second.setting->description);
+            printTable(std::cout, tbl);
+            throw Exit();
+        });
+
         mkFlag(0, "version", "show version information", std::bind(printVersion, programName));
 
         settings.convertToArgs(*this);
     }
+
+    void printFlags(std::ostream & out) override
+    {
+        Args::printFlags(out);
+        std::cout <<
+            "\n"
+            "In addition, most configuration settings can be overriden using ‘--<name> <value>’.\n"
+            "Boolean settings can be overriden using ‘--<name>’ or ‘--no-<name>’. See ‘nix\n"
+            "--help-config’ for a list of configuration settings.\n";
+    }
 };
 
 void mainWrapped(int argc, char * * argv)