diff --git a/rules_haskell_tests/tests/run-start-script.sh b/rules_haskell_tests/tests/run-start-script.sh index 27200c7e6..6c5be1c28 100755 --- a/rules_haskell_tests/tests/run-start-script.sh +++ b/rules_haskell_tests/tests/run-start-script.sh @@ -15,6 +15,26 @@ mkdir $workdir cd $workdir cp "$rules_haskell_dir/.bazelversion" . +function getattr_value() { + local nix_file="$rules_haskell_dir/nixpkgs/default.nix" + while IFS=$' \t;' read -r key eq value rest ; do + if [ "$key" == "$1" ] && [ "$eq" == '=' ]; then + value="${value%\"}" + value="${value#\"}" + + echo "$value" + return + fi + done < "$nix_file" + echo "could not lookup ${1} in $nix_file" >&2 + exit 1 +} + +NIXPKGS_REVISION=$( getattr_value "rev" ) +NIXPKGS_HASH=$( nix hash to-base64 "$(getattr_value "sha256")" ) + +export NIXPKGS_REVISION NIXPKGS_HASH + # specify version for bazelisk via `USE_BAZEL_VERSION`, since it does not read the .bazelversion when there is no WORKSPACE file USE_BAZEL_VERSION=$( cat .bazelversion ) export USE_BAZEL_VERSION diff --git a/start b/start index d28823f31..a306f6388 100755 --- a/start +++ b/start @@ -9,6 +9,8 @@ set -eu # we use the default version (currently "9.4.6"). GHC_VERSION=${GHC_VERSION:="9.4.6"} +NIXPKGS_REVISION=${NIXPKGS_REVISION:-nixos-24.05} + readonly MIN_BAZEL_MAJOR=6 readonly MIN_BAZEL_MINOR=0 @@ -328,7 +330,8 @@ EOF # https://github.com/tweag/rules_nixpkgs/blob/master/README.md nixpkgs_git_repository( name = "nixpkgs", - revision = "nixos-24.05", + revision = "${NIXPKGS_REVISION}",${NIXPKGS_HASH:+ + sha256 = \"$NIXPKGS_HASH\",} ) nixpkgs_cc_configure(