Skip to content

Commit fa85e47

Browse files
committed
Use our nixpkgs revision for the start script too
This avoids pulling down a different ghc version than is used for the tests on CI.
1 parent c3fdf91 commit fa85e47

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

rules_haskell_tests/tests/run-start-script.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ mkdir $workdir
1515
cd $workdir
1616
cp "$rules_haskell_dir/.bazelversion" .
1717

18+
function getattr_value() {
19+
local nix_file="$rules_haskell_dir/nixpkgs/default.nix"
20+
while IFS=$' \t;' read -r key eq value rest ; do
21+
if [ "$key" == "$1" ] && [ "$eq" == '=' ]; then
22+
value="${value%\"}"
23+
value="${value#\"}"
24+
25+
echo "$value"
26+
return
27+
fi
28+
done < "$nix_file"
29+
echo "could not lookup ${1} in $nix_file" >&2
30+
exit 1
31+
}
32+
33+
function have() {
34+
command -v "$1" &> /dev/null
35+
}
36+
37+
if have nix; then
38+
NIXPKGS_REVISION=$( getattr_value "rev" )
39+
NIXPKGS_HASH=$( nix hash to-sri "$(getattr_value "sha256")" )
40+
fi
41+
42+
export NIXPKGS_REVISION NIXPKGS_HASH
43+
1844
# specify version for bazelisk via `USE_BAZEL_VERSION`, since it does not read the .bazelversion when there is no WORKSPACE file
1945
USE_BAZEL_VERSION=$( cat .bazelversion )
2046
export USE_BAZEL_VERSION

start

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set -eu
99
# we use the default version (currently "9.4.6").
1010
GHC_VERSION=${GHC_VERSION:="9.4.6"}
1111

12+
NIXPKGS_REVISION=${NIXPKGS_REVISION:-nixos-24.05}
13+
1214
readonly MIN_BAZEL_MAJOR=6
1315
readonly MIN_BAZEL_MINOR=0
1416

@@ -328,7 +330,8 @@ EOF
328330
# https://github.com/tweag/rules_nixpkgs/blob/master/README.md
329331
nixpkgs_git_repository(
330332
name = "nixpkgs",
331-
revision = "nixos-24.05",
333+
revision = "${NIXPKGS_REVISION}",${NIXPKGS_HASH:+
334+
integrity = \"$NIXPKGS_HASH\",}
332335
)
333336
334337
nixpkgs_cc_configure(

0 commit comments

Comments
 (0)