File tree 2 files changed +50
-3
lines changed
rules_haskell_tests/tests
2 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,34 @@ mkdir $workdir
15
15
cd $workdir
16
16
cp " $rules_haskell_dir /.bazelversion" .
17
17
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
+ # N.B. the sha256 hash attribute given to `builtins.fetchTarball` is computed after unpacking
40
+ # the archive, it is not the hash of the downloaded artifact
41
+ # NIXPKGS_HASH=$( nix hash to-sri "$(getattr_value "sha256")" )
42
+ fi
43
+
44
+ export NIXPKGS_REVISION NIXPKGS_HASH
45
+
18
46
# specify version for bazelisk via `USE_BAZEL_VERSION`, since it does not read the .bazelversion when there is no WORKSPACE file
19
47
USE_BAZEL_VERSION=$( cat .bazelversion )
20
48
export USE_BAZEL_VERSION
Original file line number Diff line number Diff line change 9
9
# we use the default version (currently "9.4.6").
10
10
GHC_VERSION=${GHC_VERSION:= " 9.4.6" }
11
11
12
+ NIXPKGS_REVISION=${NIXPKGS_REVISION:- nixos-24.05}
13
+
12
14
readonly MIN_BAZEL_MAJOR=6
13
15
readonly MIN_BAZEL_MINOR=0
14
16
@@ -117,13 +119,29 @@ check_files_dont_exist () {
117
119
done
118
120
}
119
121
122
+ have () {
123
+ command -v " $1 " > /dev/null 2>&1
124
+ }
125
+
120
126
check_bazel_version () {
121
- actual_raw=$( bazel version | grep -E ' ^Build label:' | grep -Eo ' [0-9.]+' )
127
+ if ! have bazel; then
128
+ # shellcheck disable=SC2016
129
+ stderr ' Warning: cannot find `bazel` executable in $PATH (skipping version check)'
130
+ return
131
+ fi
132
+ if ! actual_raw=$( bazel version | grep -E ' ^Build label:' | grep -Eo ' [0-9.]+' ) ; then
133
+ stderr ' Warning: cannot determine bazel version (skipping version check)'
134
+ return
135
+ fi
122
136
123
137
# shellcheck disable=SC2034
124
- IFS=. read -r actual_major actual_minor actual_patch << -EOF
138
+ if ! IFS=. read -r actual_major actual_minor actual_patch << -EOF
125
139
${actual_raw}
126
140
EOF
141
+ then
142
+ stderr " Warning: cannot parse version from bazel output (skipping version check)"
143
+ return
144
+ fi
127
145
128
146
expected_min=" ${MIN_BAZEL_MAJOR} .${MIN_BAZEL_MINOR} .0"
129
147
expected_max=" ${MAX_BAZEL_MAJOR} .${MAX_BAZEL_MINOR} .x"
328
346
# https://github.com/tweag/rules_nixpkgs/blob/master/README.md
329
347
nixpkgs_git_repository(
330
348
name = "nixpkgs",
331
- revision = "nixos-24.05",
349
+ revision = "${NIXPKGS_REVISION} ",${NIXPKGS_HASH: +
350
+ integrity = \" $NIXPKGS_HASH \" ,}
332
351
)
333
352
334
353
nixpkgs_cc_configure(
You can’t perform that action at this time.
0 commit comments