mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
Make the flakes experimental feature stable
This commit is contained in:
parent
7747a501db
commit
590920eed2
27 changed files with 59 additions and 107 deletions
|
@ -4,7 +4,7 @@ source common.sh
|
|||
|
||||
requireDaemonNewerThan "2.4pre20210626"
|
||||
|
||||
enableFeatures "ca-derivations nix-command flakes"
|
||||
enableFeatures "ca-derivations nix-command"
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
cd ..
|
||||
|
|
|
@ -12,7 +12,7 @@ if isTestOnNixOS; then
|
|||
! test -e "$test_nix_conf"
|
||||
cat > "$test_nix_conf_dir/nix.conf" <<EOF
|
||||
# TODO: this is not needed for all tests and prevents stable commands from be tested in isolation
|
||||
experimental-features = nix-command flakes
|
||||
experimental-features = nix-command
|
||||
flake-registry = $TEST_ROOT/registry.json
|
||||
show-trace = true
|
||||
EOF
|
||||
|
@ -58,7 +58,6 @@ EOF
|
|||
|
||||
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
||||
fsync-metadata = false
|
||||
extra-experimental-features = flakes
|
||||
!include nix.conf.extra.not-there
|
||||
EOF
|
||||
|
||||
|
|
|
@ -59,13 +59,11 @@ var=$(nix config show | grep '^experimental-features =' | cut -d '=' -f 2 | xarg
|
|||
|
||||
# Test that it's possible to load config from the environment
|
||||
prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
|
||||
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command flakes"
|
||||
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command"
|
||||
exp_cores=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
|
||||
exp_features=$(nix config show | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
|
||||
[[ $prev != $exp_cores ]]
|
||||
[[ $exp_cores == "4242" ]]
|
||||
# flakes implies fetch-tree
|
||||
[[ $exp_features == "fetch-tree flakes nix-command" ]]
|
||||
|
||||
# Test that it's possible to retrieve a single setting's value
|
||||
val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -140,9 +140,9 @@ EOF
|
|||
testReplResponse '
|
||||
foo + baz
|
||||
' "3" \
|
||||
./flake ./flake\#bar --experimental-features 'flakes'
|
||||
./flake ./flake\#bar
|
||||
|
||||
# Test the `:reload` mechansim with flakes:
|
||||
# Test the `:reload` mechanism with flakes:
|
||||
# - Eval `./flake#changingThing`
|
||||
# - Modify the flake
|
||||
# - Re-eval it
|
||||
|
@ -153,7 +153,7 @@ sleep 1 # Leave the repl the time to eval 'foo'
|
|||
sed -i 's/beforeChange/afterChange/' flake/flake.nix
|
||||
echo ":reload"
|
||||
echo "changingThing"
|
||||
) | nix repl ./flake --experimental-features 'flakes')
|
||||
) | nix repl ./flake)
|
||||
echo "$replResult" | grepQuiet -s beforeChange
|
||||
echo "$replResult" | grepQuiet -s afterChange
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue