lix-releng-staging/tests/functional/impure-eval.sh
eldritch horrors 7614aa9797 Merge pull request #4093 from matthewbauer/eval-system
Add eval-system option

(cherry picked from commit 071dbbee33af9f27338c3e53e4ea067dbfa14010)
Change-Id: Ia81358c8cfb60241da07a4d0e84b9ee62a18a53f
2024-03-04 07:21:01 +01:00

36 lines
1.1 KiB
Bash

source common.sh
export REMOTE_STORE="dummy://"
simpleTest () {
local expr=$1; shift
local result=$1; shift
# rest, extra args
[[ "$(nix eval --impure --raw "$@" --expr "$expr")" == "$result" ]]
}
# `builtins.storeDir`
## Store dir follows `store` store setting
simpleTest 'builtins.storeDir' '/foo' --store "$REMOTE_STORE?store=/foo"
simpleTest 'builtins.storeDir' '/bar' --store "$REMOTE_STORE?store=/bar"
# `builtins.currentSystem`
## `system` alone affects by default
simpleTest 'builtins.currentSystem' 'foo' --system 'foo'
simpleTest 'builtins.currentSystem' 'bar' --system 'bar'
## `system` affects if `eval-system` is an empty string
simpleTest 'builtins.currentSystem' 'foo' --system 'foo' --eval-system ''
simpleTest 'builtins.currentSystem' 'bar' --system 'bar' --eval-system ''
## `eval-system` alone affects
simpleTest 'builtins.currentSystem' 'foo' --eval-system 'foo'
simpleTest 'builtins.currentSystem' 'bar' --eval-system 'bar'
## `eval-system` overrides `system`
simpleTest 'builtins.currentSystem' 'bar' --system 'foo' --eval-system 'bar'
simpleTest 'builtins.currentSystem' 'baz' --system 'foo' --eval-system 'baz'