mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Fix some issues with experimental config settings
Issues: 1. Features gated on disabled experimental settings should warn and be ignored, not silently succeed. 2. Experimental settings in the same config "batch" (file or env var) as the enabling of the experimental feature should work. 3. For (2), the order should not matter. These are analogous to the issues @roberth caught with my changes for arg handling, but they are instead for config handling. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
3f9589f17e
commit
2c8475600d
7 changed files with 238 additions and 66 deletions
|
@ -23,20 +23,64 @@ source common.sh
|
|||
# # Medium case, the configuration effects --help
|
||||
# grep_both_ways store gc --help
|
||||
|
||||
expect 1 nix --experimental-features 'nix-command' show-config --flake-registry 'https://no'
|
||||
nix --experimental-features 'nix-command flakes' show-config --flake-registry 'https://no'
|
||||
# Test settings that are gated on experimental features; the setting is ignored
|
||||
# with a warning if the experimental feature is not enabled. The order of the
|
||||
# `setting = value` lines in the configuration should not matter.
|
||||
|
||||
# 'flakes' experimental-feature is disabled before, ignore and warn
|
||||
NIX_CONFIG='
|
||||
experimental-features = nix-command
|
||||
accept-flake-config = true
|
||||
' nix show-config 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
|
||||
|
||||
# 'flakes' experimental-feature is disabled after, ignore and warn
|
||||
NIX_CONFIG='
|
||||
accept-flake-config = true
|
||||
experimental-features = nix-command
|
||||
' nix show-config 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
|
||||
|
||||
# 'flakes' experimental-feature is enabled before, process
|
||||
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
|
||||
grepQuiet "true" $TEST_ROOT/stdout
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
|
||||
# 'flakes' experimental-feature is enabled after, process
|
||||
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
|
||||
grepQuiet "true" $TEST_ROOT/stdout
|
||||
grepQuietInverse "Ignoring setting 'accept-flake-config'" $TEST_ROOT/stderr
|
||||
|
||||
function exit_code_both_ways {
|
||||
expect 1 nix --experimental-features 'nix-command' "$@" 1>/dev/null
|
||||
nix --experimental-features 'nix-command flakes' "$@" 1>/dev/null
|
||||
|
||||
# Also, the order should not matter
|
||||
expect 1 nix "$@" --experimental-features 'nix-command' 1>/dev/null
|
||||
nix "$@" --experimental-features 'nix-command flakes' 1>/dev/null
|
||||
}
|
||||
|
||||
exit_code_both_ways show-config --flake-registry 'https://no'
|
||||
|
||||
# Double check these are stable
|
||||
nix --experimental-features '' --help
|
||||
nix --experimental-features '' doctor --help
|
||||
nix --experimental-features '' repl --help
|
||||
nix --experimental-features '' upgrade-nix --help
|
||||
nix --experimental-features '' --help 1>/dev/null
|
||||
nix --experimental-features '' doctor --help 1>/dev/null
|
||||
nix --experimental-features '' repl --help 1>/dev/null
|
||||
nix --experimental-features '' upgrade-nix --help 1>/dev/null
|
||||
|
||||
# These 3 arguments are currently given to all commands, which is wrong (as not
|
||||
# all care). To deal with fixing later, we simply make them require the
|
||||
# nix-command experimental features --- it so happens that the commands we wish
|
||||
# stabilizing to do not need them anyways.
|
||||
for arg in '--print-build-logs' '--offline' '--refresh'; do
|
||||
nix --experimental-features 'nix-command' "$arg" --help
|
||||
! nix --experimental-features '' "$arg" --help
|
||||
nix --experimental-features 'nix-command' "$arg" --help 1>/dev/null
|
||||
expect 1 nix --experimental-features '' "$arg" --help 1>/dev/null
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue