Add functional tests for include directive in nix config file

This commit is contained in:
Cameron Dart 2024-04-02 18:10:36 -07:00
parent 478c05308c
commit ba0bd8fae6
4 changed files with 16 additions and 1 deletions

View File

@ -43,6 +43,16 @@ export NIX_USER_CONF_FILES=$here/config/nix-with-substituters.conf
var=$(nix config show | grep '^substituters =' | cut -d '=' -f 2 | xargs) var=$(nix config show | grep '^substituters =' | cut -d '=' -f 2 | xargs)
[[ $var == https://example.com ]] [[ $var == https://example.com ]]
# Test that we can include a file.
export NIX_USER_CONF_FILES=$here/config/nix-with-include.conf
var=$(nix config show | grep '^allowed-uris =' | cut -d '=' -f 2 | xargs)
[[ $var == https://github.com/NixOS/nix ]]
# Test that we can !include a file.
export NIX_USER_CONF_FILES=$here/config/nix-with-bang-include.conf
var=$(nix config show | grep '^experimental-features =' | cut -d '=' -f 2 | xargs)
[[ $var == nix-command ]]
# Test that it's possible to load config from the environment # Test that it's possible to load config from the environment
prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs) 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 flakes"
@ -56,4 +66,4 @@ exp_features=$(nix config show | grep '^experimental-features' | cut -d '=' -f 2
# Test that it's possible to retrieve a single setting's value # Test that it's possible to retrieve a single setting's value
val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs) val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
val2=$(nix config show warn-dirty) val2=$(nix config show warn-dirty)
[[ $val == $val2 ]] [[ $val == $val2 ]]

View File

@ -0,0 +1 @@
allowed-uris = https://github.com/NixOS/nix

View File

@ -0,0 +1,2 @@
experimental-features = nix-command
!include ./missing-extra-config.conf

View File

@ -0,0 +1,2 @@
experimental-features = nix-command
include ./extra-config.conf