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

Make the flakes experimental feature stable

This commit is contained in:
Graham Christensen 2023-10-29 21:50:35 +00:00 committed by Eelco Dolstra
parent 7747a501db
commit 590920eed2
27 changed files with 59 additions and 107 deletions

View file

@ -12,11 +12,11 @@ source common.sh
#
# function grep_both_ways {
# nix --experimental-features 'nix-command' "$@" | grepQuietInverse flake
# nix --experimental-features 'nix-command flakes' "$@" | grepQuiet flake
# nix --experimental-features 'nix-command' "$@" | grepQuiet flake
#
# # Also, the order should not matter
# nix "$@" --experimental-features 'nix-command' | grepQuietInverse flake
# nix "$@" --experimental-features 'nix-command flakes' | grepQuiet flake
# nix "$@" --experimental-features 'nix-command' | grepQuiet flake
# }
#
# # Simple case, the configuration effects the running command
@ -29,50 +29,50 @@ source common.sh
# 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='
xpFeature=auto-allocate-uids
gatedSetting=auto-allocate-uids
# Experimental feature is disabled before, ignore and warn.
NIX_CONFIG="
experimental-features = nix-command
accept-flake-config = true
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
$gatedSetting = true
" expect 1 nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
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"
grepQuiet "error: could not find setting '$gatedSetting'" "$TEST_ROOT/stderr"
# 'flakes' experimental-feature is disabled after, ignore and warn
NIX_CONFIG='
accept-flake-config = true
# Experimental feature is disabled after, ignore and warn.
NIX_CONFIG="
$gatedSetting = true
experimental-features = nix-command
' expect 1 nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
" expect 1 nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
[[ $(cat "$TEST_ROOT/stdout") = '' ]]
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"
grepQuiet "error: could not find setting '$gatedSetting'" "$TEST_ROOT/stderr"
# 'flakes' experimental-feature is enabled before, process
NIX_CONFIG='
experimental-features = nix-command flakes
accept-flake-config = true
' nix config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
# Experimental feature is enabled before, process.
NIX_CONFIG="
experimental-features = nix-command $xpFeature
$gatedSetting = true
" nix config show $gatedSetting 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 config show accept-flake-config 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
# Experimental feature is enabled after, process.
NIX_CONFIG="
$gatedSetting = true
experimental-features = nix-command $xpFeature
" nix config show $gatedSetting 1>"$TEST_ROOT"/stdout 2>"$TEST_ROOT"/stderr
grepQuiet "true" "$TEST_ROOT/stdout"
grepQuietInverse "Ignoring setting 'accept-flake-config'" "$TEST_ROOT/stderr"
grepQuietInverse "Ignoring setting '$gatedSetting'" "$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
expect 1 nix --experimental-features 'nix-command ' "$@" 1>/dev/null
nix --experimental-features "nix-command $xpFeature" "$@" 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
nix "$@" --experimental-features "nix-command $xpFeature" 1>/dev/null
}
exit_code_both_ways show-config --flake-registry 'https://no'
exit_code_both_ways config show --auto-allocate-uids
# Double check these are stable
nix --experimental-features '' --help 1>/dev/null