Skip to content

Commit d179c7e

Browse files
authored
tools: migrate from openssl-matrix.json to openssl-matrix.nix
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: nodejs#63036 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 9ab960a commit d179c7e

6 files changed

Lines changed: 62 additions & 119 deletions

File tree

.github/workflows/test-shared.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ jobs:
172172
name: 'aarch64-linux: Cache V8 build'
173173
outputs:
174174
local-cache: ${{ steps.upload.outcome != 'skipped' && 'true' || '' }}
175+
matrix: ${{ steps.query.outputs.matrix }}
175176
steps:
176177
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
177178
with:
@@ -227,25 +228,17 @@ jobs:
227228
name: libv8
228229
path: libv8
229230

230-
# Builds the matrix for `build-openssl` from tools/nix/openssl-matrix.json.
231-
# Output shape:
232-
# [{ "version": "3.6.1", "attr": "openssl_3_6", "continue-on-error": false }, ...]
233-
collect-openssl-versions:
234-
if: github.event.pull_request.draft == false
235-
runs-on: ubuntu-slim
236-
outputs:
237-
matrix: ${{ steps.query.outputs.matrix }}
238-
steps:
239-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
240-
with:
241-
persist-credentials: false
242-
sparse-checkout: tools/nix/openssl-matrix.json
243-
sparse-checkout-cone-mode: false
244-
- id: query
231+
- name: Collect matrix of support OpenSSL versions
232+
id: query
245233
run: |
246234
{
247235
echo 'matrix<<EOF'
248-
cat tools/nix/openssl-matrix.json
236+
nix-instantiate --eval --strict --json -E "
237+
let
238+
matrix = import $TAR_DIR/tools/nix/openssl-matrix.nix {};
239+
in
240+
builtins.map (attr: { inherit attr; inherit (builtins.getAttr attr matrix) name; }) (builtins.attrNames matrix)
241+
"
249242
echo 'EOF'
250243
} >> "$GITHUB_OUTPUT"
251244
@@ -255,19 +248,16 @@ jobs:
255248
# entry, while all other shared libs remain at their defaults. Only runs on
256249
# a single runner/system (aarch64-linux) to keep the matrix to a minimum.
257250
build-openssl:
258-
needs:
259-
- build-aarch64-linux-v8
260-
- collect-openssl-versions
251+
needs: build-aarch64-linux-v8
261252
strategy:
262253
fail-fast: false
263254
matrix:
264-
openssl: ${{ fromJSON(needs.collect-openssl-versions.outputs.matrix) }}
265-
name: 'aarch64-linux: with shared ${{ matrix.openssl.attr }} (${{ matrix.openssl.version }})'
255+
openssl: ${{ fromJSON(needs.build-aarch64-linux-v8.outputs.matrix) }}
256+
name: 'aarch64-linux: with shared ${{ matrix.openssl.name }}'
266257
runs-on: ubuntu-24.04-arm
267-
continue-on-error: ${{ matrix.openssl['continue-on-error'] }}
258+
continue-on-error: false
268259
env:
269260
OPENSSL_ATTR: ${{ matrix.openssl.attr }}
270-
OPENSSL_VERSION: ${{ matrix.openssl.version }}
271261
steps:
272262
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
273263
with:
@@ -293,5 +283,5 @@ jobs:
293283
extra-nix-flags: |
294284
--arg useSeparateDerivationForV8 ${{ needs.build-aarch64-linux-v8.outputs.local-cache && '"$(nix-store --import < libv8)"' || 'true' }} \
295285
--arg sharedLibDeps "(import $TAR_DIR/tools/nix/sharedLibDeps.nix {}) // {
296-
openssl = (import $TAR_DIR/tools/nix/pkgs.nix { config.permittedInsecurePackages = [ \"openssl-$OPENSSL_VERSION\" ]; }).$OPENSSL_ATTR;
286+
openssl = (import $TAR_DIR/tools/nix/openssl-matrix.nix {}).$OPENSSL_ATTR;
297287
}" \

tools/dep_updaters/update-nixpkgs-pin.sh

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -ex
55

66
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
77
NIXPKGS_PIN_FILE="$BASE_DIR/tools/nix/pkgs.nix"
8-
OPENSSL_MATRIX_FILE="$BASE_DIR/tools/nix/openssl-matrix.json"
8+
OPENSSL_MATRIX_FILE="$BASE_DIR/tools/nix/openssl-matrix.nix"
99

1010
NIXPKGS_REPO=$(grep 'repo =' "$NIXPKGS_PIN_FILE" | awk -F'"' '{ print $2 }')
1111
CURRENT_VERSION_SHA1=$(grep 'rev =' "$NIXPKGS_PIN_FILE" | awk -F'"' '{ print $2 }')
@@ -26,7 +26,37 @@ TMP_FILE=$(mktemp)
2626
sed "s/$CURRENT_VERSION_SHA1/$NEW_UPSTREAM_SHA1/;s/$CURRENT_TARBALL_HASH/$NEW_TARBALL_HASH/" "$NIXPKGS_PIN_FILE" > "$TMP_FILE"
2727
mv "$TMP_FILE" "$NIXPKGS_PIN_FILE"
2828

29-
"$BASE_DIR/tools/nix/collect-openssl-matrix.sh" | jq . > "$OPENSSL_MATRIX_FILE"
29+
nix-instantiate -I "nixpkgs=$NIXPKGS_PIN_FILE" --eval --strict --json -E "
30+
let
31+
pkgs = import <nixpkgs> {};
32+
attrs = builtins.filter
33+
(n:
34+
let t = builtins.tryEval pkgs.\${n}; in
35+
t.success && (builtins.tryEval t.value.version).success
36+
)
37+
(
38+
builtins.filter
39+
(n: builtins.match \"openssl_[0-9]+(_[0-9]+)?\" n != null)
40+
(builtins.attrNames pkgs)
41+
);
42+
in
43+
{
44+
inherit attrs;
45+
permittedInsecurePackages = builtins.map (attr: pkgs.\${attr}.name) (
46+
builtins.filter (attr: (pkgs.\${attr}.meta.insecure)) attrs
47+
);
48+
}
49+
" | jq -r '"{
50+
pkgs ? import ./pkgs.nix {
51+
config.permittedInsecurePackages = [ \(.permittedInsecurePackages | map(@json) | join(" ")) ];
52+
},
53+
}:
54+
55+
{
56+
inherit (pkgs)
57+
\(.attrs | join("\n "))
58+
;
59+
}"' > "$OPENSSL_MATRIX_FILE"
3060

3161
cat -<<EOF
3262
All done!

tools/nix/collect-openssl-matrix.sh

Lines changed: 0 additions & 65 deletions
This file was deleted.

tools/nix/openssl-matrix.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

tools/nix/openssl-matrix.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
pkgs ? import ./pkgs.nix {
3+
config.permittedInsecurePackages = [ "openssl-1.1.1w" ];
4+
},
5+
}:
6+
7+
{
8+
inherit (pkgs)
9+
openssl_1_1
10+
openssl_3
11+
openssl_3_5
12+
openssl_3_6
13+
openssl_4_0
14+
;
15+
}

tools/nix/sharedLibDeps.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
ffi = pkgs.libffiReal;
4949
})
5050
// (pkgs.lib.optionalAttrs withSSL ({
51-
openssl = pkgs.openssl_3_5;
51+
openssl = (import ./openssl-matrix.nix { inherit pkgs; }).openssl_3_5;
5252
}))
5353
// (pkgs.lib.optionalAttrs withTemporal {
5454
inherit (pkgs) temporal_capi;

0 commit comments

Comments
 (0)