Skip to content

Commit 2bcc3e8

Browse files
committed
tools: migrate from openssl-matrix.json to openssl-matrix.nix
Signed-off-by: Antoine du Hamel <[email protected]>
1 parent af8eba2 commit 2bcc3e8

6 files changed

Lines changed: 60 additions & 90 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: 2 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,7 @@ 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+
"$BASE_DIR/tools/nix/collect-openssl-matrix.sh" > "$OPENSSL_MATRIX_FILE"
3030

3131
cat -<<EOF
3232
All done!

tools/nix/collect-openssl-matrix.sh

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,34 @@ here=$(cd -- "$(dirname -- "$0")" && pwd)
2424
# repo-pinned nixpkgs. `tryEval` skips aliases that raise (e.g.
2525
# `openssl_3_0` → renamed to `openssl_3`) so we only keep attributes
2626
# that resolve to a real derivation with a `.version`.
27-
nix_json=$(nix-instantiate --eval --strict --json -E "
27+
nix-instantiate --eval --strict --json -E "
2828
let
2929
pkgs = import $here/pkgs.nix {};
30-
names = builtins.filter
31-
(n: builtins.match \"openssl_[0-9]+(_[0-9]+)?\" n != null)
32-
(builtins.attrNames pkgs);
33-
safe = builtins.filter (n:
34-
let t = builtins.tryEval pkgs.\${n}; in
35-
t.success && (builtins.tryEval t.value.version).success) names;
36-
in map (n: { attr = n; version = pkgs.\${n}.version; }) safe
37-
")
30+
attrs = builtins.filter
31+
(n:
32+
let t = builtins.tryEval pkgs.\${n}; in
33+
t.success && (builtins.tryEval t.value.version).success
34+
)
35+
(
36+
builtins.filter
37+
(n: builtins.match \"openssl_[0-9]+(_[0-9]+)?\" n != null)
38+
(builtins.attrNames pkgs)
39+
);
40+
in
41+
{
42+
inherit attrs;
43+
permittedInsecurePackages = builtins.map (attr: pkgs.\${attr}.name) (
44+
builtins.filter (attr: (pkgs.\${attr}.meta.insecure)) attrs
45+
);
46+
}
47+
" | jq -r '"{
48+
pkgs ? import ./pkgs.nix {
49+
config.permittedInsecurePackages = [ \(.permittedInsecurePackages | map(@json) | join(" ")) ];
50+
},
51+
}:
3852
39-
# 2. Fetch OpenSSL release versions from endoflife.date, keep entries that
40-
# are either not past EOL or still under extended support, then pick the
41-
# first nix attr whose `.version` starts with the release version
42-
# followed by `.` / letter / end-of-string (so "3.6" matches "3.6.1",
43-
# "1.1.1" matches "1.1.1w", and "1.1" does NOT swallow "1.1.1").
44-
# Releases without a matching nix attr are dropped.
45-
curl -sf https://endoflife.date/api/openssl.json \
46-
| jq -c \
47-
--argjson nix "$nix_json" \
48-
--arg supported "$SUPPORTED_OPENSSL_VERSION" '
49-
(now | strftime("%Y-%m-%d")) as $today |
50-
# Compare OpenSSL major.minor cycles as numeric tuples.
51-
def cycle_tuple($v):
52-
($v | split(".") | map(tonumber));
53-
[ .[]
54-
| select(.eol == false or .eol > $today or .extendedSupport == true)
55-
| .cycle as $v
56-
| ($nix
57-
| map(select(.version | test("^" + ($v | gsub("\\."; "\\.")) + "([.a-z]|$)")))
58-
| first) as $m
59-
| select($m != null)
60-
| {
61-
version: $m.version,
62-
attr: $m.attr,
63-
"continue-on-error": (cycle_tuple($v) > cycle_tuple($supported))
64-
}
65-
]'
53+
{
54+
inherit (pkgs)
55+
\(.attrs | join("\n "))
56+
;
57+
}"'

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)