Skip to content

Commit

Permalink
Merge pull request NixOS#10386 from SkamDart/SkamDart/include-directi…
Browse files Browse the repository at this point in the history
…ve-config-test

Add functional tests for include directives in nix config file
  • Loading branch information
thufschmitt committed Apr 3, 2024
2 parents 478c053 + ba0bd8f commit 5536788
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/functional/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 == 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
prev=$(nix config show | grep '^cores' | cut -d '=' -f 2 | xargs)
export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command flakes"
Expand All @@ -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
val=$(nix config show | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
val2=$(nix config show warn-dirty)
[[ $val == $val2 ]]
[[ $val == $val2 ]]
1 change: 1 addition & 0 deletions tests/functional/config/extra-config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allowed-uris = https://github.com/NixOS/nix
2 changes: 2 additions & 0 deletions tests/functional/config/nix-with-bang-include.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
experimental-features = nix-command
!include ./missing-extra-config.conf
2 changes: 2 additions & 0 deletions tests/functional/config/nix-with-include.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
experimental-features = nix-command
include ./extra-config.conf

0 comments on commit 5536788

Please sign in to comment.