Skip to content

Commit ae4b8df

Browse files
committed
tools: store "default" OpenSSL version in openssl-matrix.nix
To help with automating keeping in sync with the bundled version. Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #64962 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent 94d12f3 commit ae4b8df

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

tools/dep_updaters/update-nixpkgs-pin.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,39 @@ 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+
# === Update openssl-matrix.nix ===
30+
# When bumping the pin, we want to update the openssl-matrix.nix file to keep the list in sync nixpkgs
31+
# i.e. add newly added release lines, remove newly dropped release lines), and make sure the "openssl"
32+
# attribute still refers to the same release line as the bundled version in deps/openssl/.
33+
34+
OPENSSL_MAJOR=$(awk -F= '/^MAJOR=[0-9]+$/ { print $2; exit }' "$BASE_DIR/deps/openssl/openssl/VERSION.dat")
35+
OPENSSL_MINOR=$(awk -F= '/^MINOR=[0-9]+$/ { print $2; exit }' "$BASE_DIR/deps/openssl/openssl/VERSION.dat")
36+
2937
nix-instantiate -I "nixpkgs=$NIXPKGS_PIN_FILE" --eval --strict --json -E "
3038
let
3139
pkgs = import <nixpkgs> {};
3240
opensslAttrs = builtins.filter
3341
(n: builtins.match \"openssl_[0-9]+(_[0-9]+)?\" n != null)
3442
(builtins.attrNames pkgs);
3543
extraMatrixAttrs = [ \"boringssl\" ];
44+
default = builtins.head (builtins.filter (n:
45+
let
46+
inherit (pkgs.lib) versions;
47+
t = builtins.tryEval pkgs.\${n};
48+
v = if t.success then builtins.tryEval t.value.version else t;
49+
majorVersion = pkgs.lib.optionalString v.success (versions.major v.value);
50+
minorVersion = pkgs.lib.optionalString v.success (versions.minor v.value);
51+
in
52+
majorVersion == ''$OPENSSL_MAJOR'' && minorVersion == ''$OPENSSL_MINOR'') opensslAttrs);
3653
attrs = builtins.filter
3754
(n:
3855
let t = builtins.tryEval pkgs.\${n}; in
39-
t.success && (builtins.tryEval t.value.version).success
56+
n != default && t.success && (builtins.tryEval t.value.version).success
4057
)
4158
(opensslAttrs ++ extraMatrixAttrs);
4259
in
4360
{
44-
inherit attrs;
61+
inherit attrs default;
4562
permittedInsecurePackages = builtins.map (attr: pkgs.\${attr}.name) (
4663
builtins.filter (attr: (pkgs.\${attr}.meta.insecure)) attrs
4764
);
@@ -53,6 +70,10 @@ nix-instantiate -I "nixpkgs=$NIXPKGS_PIN_FILE" --eval --strict --json -E "
5370
}:
5471
5572
{
73+
# "default" OpenSSL release line, should be kept in sync with the bundled version:
74+
openssl = pkgs.\(.default);
75+
76+
# Other OpenSSL variants we want to test for:
5677
inherit (pkgs)
5778
\(.attrs | sort | join("\n "))
5879
;

tools/nix/openssl-matrix.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
}:
66

77
{
8+
# "default" OpenSSL release line, should be kept in sync with the bundled version:
9+
openssl = pkgs.openssl_3_5;
10+
11+
# Other OpenSSL variants we want to test for:
812
inherit (pkgs)
913
boringssl
1014
openssl_1_1
1115
openssl_3
12-
openssl_3_5
1316
openssl_3_6
1417
openssl_4_0
1518
;

tools/nix/pkcs11.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# pkcs11-provider is dlopen'd into the libcrypto Node.js itself links, so it
1111
# has to be built against that very OpenSSL. SoftHSM links OpenSSL too;
1212
# building it against the same one keeps a single libcrypto in the process.
13-
openssl ? (import ./sharedLibDeps.nix { inherit pkgs; }).openssl,
13+
openssl ? (import ./openssl-matrix.nix { inherit pkgs; }).openssl,
1414

1515
pin ? "1234",
1616
}:

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 = (import ./openssl-matrix.nix { inherit pkgs; }).openssl_3_5;
51+
inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl;
5252
}))
5353
// (pkgs.lib.optionalAttrs withTemporal {
5454
inherit (pkgs) temporal_capi;

0 commit comments

Comments
 (0)