1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 14:21:48 +02:00

Merge pull request #10050 from NixOS/backport-10049-to-2.20-maintenance

[Backport 2.20-maintenance] Don't send settings that depend on disabled experimental features to the daemon
This commit is contained in:
Eelco Dolstra 2024-02-21 13:05:51 +01:00 committed by GitHub
commit 8a8172cd2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 6 deletions

View file

@ -4,7 +4,7 @@
* *
* Template implementations (as opposed to mere declarations). * Template implementations (as opposed to mere declarations).
* *
* This file is an exmample of the "impl.hh" pattern. See the * This file is an example of the "impl.hh" pattern. See the
* contributing guide. * contributing guide.
* *
* One only needs to include this when one is declaring a * One only needs to include this when one is declaring a

View file

@ -84,7 +84,9 @@ void AbstractConfig::reapplyUnknownSettings()
void Config::getSettings(std::map<std::string, SettingInfo> & res, bool overriddenOnly) void Config::getSettings(std::map<std::string, SettingInfo> & res, bool overriddenOnly)
{ {
for (const auto & opt : _settings) for (const auto & opt : _settings)
if (!opt.second.isAlias && (!overriddenOnly || opt.second.setting->overridden)) if (!opt.second.isAlias
&& (!overriddenOnly || opt.second.setting->overridden)
&& experimentalFeatureSettings.isEnabled(opt.second.setting->experimentalFeature))
res.emplace(opt.first, SettingInfo{opt.second.setting->to_string(), opt.second.setting->description}); res.emplace(opt.first, SettingInfo{opt.second.setting->to_string(), opt.second.setting->description});
} }

View file

@ -31,17 +31,19 @@ source common.sh
NIX_CONFIG=' NIX_CONFIG='
experimental-features = nix-command experimental-features = nix-command
accept-flake-config = true accept-flake-config = true
' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr ' expect 1 nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "false" $TEST_ROOT/stdout [[ $(cat $TEST_ROOT/stdout) = '' ]]
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
grepQuiet "error: could not find setting 'accept-flake-config'" $TEST_ROOT/stderr
# 'flakes' experimental-feature is disabled after, ignore and warn # 'flakes' experimental-feature is disabled after, ignore and warn
NIX_CONFIG=' NIX_CONFIG='
accept-flake-config = true accept-flake-config = true
experimental-features = nix-command experimental-features = nix-command
' nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr ' expect 1 nix config show accept-flake-config 1>$TEST_ROOT/stdout 2>$TEST_ROOT/stderr
grepQuiet "false" $TEST_ROOT/stdout [[ $(cat $TEST_ROOT/stdout) = '' ]]
grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr grepQuiet "Ignoring setting 'accept-flake-config' because experimental feature 'flakes' is not enabled" $TEST_ROOT/stderr
grepQuiet "error: could not find setting 'accept-flake-config'" $TEST_ROOT/stderr
# 'flakes' experimental-feature is enabled before, process # 'flakes' experimental-feature is enabled before, process
NIX_CONFIG=' NIX_CONFIG='