mirror of
https://github.com/numtide/nix-filter.git
synced 2024-08-16 09:20:34 +03:00
tests: evaluate the tests in restrict-eval mode
This simulates a stricter environment like flakes
This commit is contained in:
parent
88ec5a014d
commit
3d50f761b2
@ -6,20 +6,25 @@ set -euo pipefail
|
|||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
extra_flags=""
|
nix_args=(
|
||||||
|
# Simulate flakes. Paths that are in the include are allowed.
|
||||||
|
--include "prj_root=.."
|
||||||
|
--option restrict-eval true
|
||||||
|
--option allow-import-from-derivation false
|
||||||
|
)
|
||||||
|
|
||||||
if [[ "$#" -eq 1 ]]; then
|
if [[ "$#" -eq 1 ]]; then
|
||||||
extra_flags="-A $1"
|
nix_args+=(-A "$1")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Need to build first or the store paths don't exist
|
# Need to build first or the store paths don't exist
|
||||||
# for default.nix to traverse
|
# for default.nix to traverse
|
||||||
nix-build >/dev/null
|
nix-build "${nix_args[@]}" >/dev/null
|
||||||
echo "---------------------------------------------------------------------"
|
echo "---------------------------------------------------------------------"
|
||||||
results="$(nix-instantiate --eval --strict --json $extra_flags 2>/dev/null)"
|
results="$(nix-instantiate --eval --strict --json "${nix_args[@]}")"
|
||||||
|
|
||||||
# Normalize input before handing it over to jq
|
# Normalize input before handing it over to jq
|
||||||
if [[ -n "$extra_flags" ]] && [[ "${1::1}" != "@" ]]; then
|
if [[ "$#" -eq 1 && "${1::1}" != "@" ]]; then
|
||||||
results="{ \"$1\": $results }"
|
results="{ \"$1\": $results }"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user