aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/config.cc
AgeCommit message (Collapse)Author
2023-03-20Fix handling of experimental features mid-parseJohn Ericson
If we conditionally "declare" the argument, as we did before, based upon weather the feature is enabled, commands like nix --experimental-features=foo ... --thing-gated-on-foo won't work, because the experimental feature isn't enabled until *after* we start parsing. Instead, allow arguments to also be associated with experimental features (just as we did for builtins and settings), and then the command line parser will filter out the experimental ones. Since the effects of arguments (handler functions) are performed right away, we get the required behavior: earlier arguments can enable later arguments enabled! There is just one catch: we want to keep non-positional flags...non-positional. So if nix --experimental-features=foo ... --thing-gated-on-foo works, then nix --thing-gated-on-foo --experimental-features=foo ... should also work. This is not my favorite long-term solution, but for now this is implemented by delaying the requirement of needed experimental features until *after* all the arguments have been parsed.
2023-03-20Mark experimental features on settingsJohn Ericson
We hide them in various ways if the experimental feature isn't enabled. To do this, we had to move the experimental features list out of libnixstore, because the setting machinary itself depends on it. To do that, we made a new `ExperimentalFeatureSettings`.
2023-03-20Move enabled experimental feature to libutil structJohn Ericson
This is needed in subsequent commits to allow the settings and CLI args infrastructure itself to read this setting.
2022-10-22Fix C++20 warningsGraham Bennett
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2022-02-21Remove std::vector aliasEelco Dolstra
2021-10-27StyleEelco Dolstra
2021-10-26Make experimental-features a proper typeregnat
Rather than having them plain strings scattered through the whole codebase, create an enum containing all the known experimental features. This means that - Nix can now `warn` when an unkwown experimental feature is passed (making it much nicer to spot typos and spot deprecated features) - It’s now easy to remove a feature altogether (once the feature isn’t experimental anymore or is dropped) by just removing the field for the enum and letting the compiler point us to all the now invalid usages of it.
2021-09-22Make setDefault() typedEelco Dolstra
2021-07-15Forward the whole Nix config to the post-build-hookregnat
Fill `NIX_CONFIG` with the value of the current Nix configuration before calling the post-build-hook. That way the whole configuration (including the possible `experimental-features`, a possibly `--store` option or whatever) will be made available to the hook
2021-03-26Fix some typosEelco Dolstra
Fixes #4671.
2021-01-08string2Int(): Return std::optionalEelco Dolstra
2020-11-09Fix appending to Setting<StringSet>Eelco Dolstra
Fixes: warning: unknown setting 'extra-sandbox-paths'
2020-10-29Fix assertion failure in tab completion for --optionEelco Dolstra
2020-10-29Generalize extra-* settingsEelco Dolstra
This removes the extra-substituters and extra-sandbox-paths settings and instead makes every array setting extensible by setting "extra-<name> = <value>" in the configuration file or passing "--<name> <value>" on the command line.
2020-10-26BaseSetting<StringMap>::set(): Don't append to previous valueEelco Dolstra
2020-09-29Merge branch 'master' into access-tokensKevin Quick
2020-09-24Support StringMap configuration settings.Kevin Quick
Allows Configuration values that are space-separated key=value pairs.
2020-09-21abstractsettingtojson.hh -> abstract-setting-to-json.hhEelco Dolstra
2020-09-16Don't include nlohmann/json.hpp in config.hhregnat
Instead make a separate header with the template implementation of `BaseSetting<T>::toJSONObj` that can be included where needed
2020-09-16Complete the `toJSON` instance for `Setting<T>`regnat
Don't let it just contain the value, but also the other fields of the setting (description, aliases, etc..)
2020-08-20Allow 'nix' subcommands to provide docs in Markdown formatEelco Dolstra
2020-08-20List deprecated option aliases in the docsEelco Dolstra
2020-08-20Config: Use nlohmann/jsonEelco Dolstra
2020-08-19Generate the nix.conf docs from the source codeEelco Dolstra
This means we don't have two (divergent) sets of option descriptions anymore.
2020-05-27config.cc: extract parts of applyConfigFile into applyConfigAndreas Rammhold
This moves the actual parsing of configuration contents into applyConfig which applyConfigFile is then going to call. By changing this we can now test the configuration file parsing without actually create a file on disk.
2020-05-04Flag: Use designated initializersEelco Dolstra
2019-12-17Add priority setting to storesEelco Dolstra
This allows overriding the priority of substituters, e.g. $ nix-store --store ~/my-nix/ -r /nix/store/df3m4da96d84ljzxx4mygfshm1p0r2n3-geeqie-1.4 \ --substituters 'http://cache.nixos.org?priority=100 daemon?priority=10' Fixes #3264.
2018-05-30Modularize config settingsEelco Dolstra
Allow global config settings to be defined in multiple Config classes. For example, this means that libutil can have settings and evaluator settings can be moved out of libstore. The Config classes are registered in a new GlobalConfig class to which config files etc. are applied. Relevant to https://github.com/NixOS/nix/issues/2009 in that it removes the need for ad hoc handling of useCaseHack, which was the underlying cause of that issue.
2018-02-19Config::handleUnknownSettings(): Remove unused 'fatal' argumentEelco Dolstra
2018-02-13Allow plugins to define new settings.Shea Levy
2018-02-13Allow includes from nix.confShea Levy
2017-11-21Propagate flags like --sandbox to the daemon properlyEelco Dolstra
2017-10-24nix: Respect -I, --arg, --argstrEelco Dolstra
Also, random cleanup to argument handling.
2017-07-30Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-06-07Don't show flags from config settings in "nix --help"Eelco Dolstra
2017-06-07nix: Make all options available as flagsEelco Dolstra
Thus, instead of ‘--option <name> <value>’, you can write ‘--<name> <value>’. So --option http-connections 100 becomes --http-connections 100 Apart from brevity, the difference is that it's not an error to set a non-existent option via --option, but unrecognized arguments are fatal. Boolean options have special treatment: they're mapped to the argument-less flags ‘--<name>’ and ‘--no-<name>’. E.g. --option auto-optimise-store false becomes --no-auto-optimise-store
2017-05-03Fix build on gcc 4.9Eelco Dolstra
http://hydra.nixos.org/build/52408843
2017-04-28Hopefully fix the Darwin buildEelco Dolstra
http://hydra.nixos.org/build/52080911
2017-04-20Improve nix show-config --jsonEelco Dolstra
In particular, show descriptions. This could be used for manpage generation etc.
2017-04-20Setting: Remove "Tag" template argumentEelco Dolstra
2017-04-20Read per-user settings from ~/.config/nix/nix.confEelco Dolstra
2017-04-14Fix 32-bit buildEelco Dolstra
http://hydra.nixos.org/build/51569816
2017-04-13Convert Settings to the new config systemEelco Dolstra
This makes all config options self-documenting. Unknown or unparseable config settings and --option flags now cause a warning.
2017-04-13Support arbitrary numeric types for settingsEelco Dolstra
2017-04-13Validate Boolean settings betterEelco Dolstra
2017-04-13Add a Config class to simplify adding configuration settingsEelco Dolstra
The typical use is to inherit Config and add Setting<T> members: class MyClass : private Config { Setting<int> foo{this, 123, "foo", "the number of foos to use"}; Setting<std::string> bar{this, "blabla", "bar", "the name of the bar"}; MyClass() : Config(readConfigFile("/etc/my-app.conf")) { std::cout << foo << "\n"; // will print 123 unless overriden } }; Currently, this is used by Store and its subclasses for store parameters. You now get a warning if you specify a non-existant store parameter in a store URI.