Skip to content

Commit

Permalink
Use our nixpkgs revision for the start script too
Browse files Browse the repository at this point in the history
This avoids pulling down a different ghc version than is used for the tests on CI.
  • Loading branch information
avdv committed Dec 4, 2024
1 parent c3fdf91 commit c04d9e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions rules_haskell_tests/tests/run-start-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion start
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c04d9e0

Please sign in to comment.