Skip to content

Commit 3390622

Browse files
authored
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 bd2e603 commit 3390622

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
@@ -42,22 +42,39 @@ COMPAT_VERSION_SHA1=$(grep 'rev =' "$NIXPKGS_COMPAT_PIN_FILE" | awk -F'"' '{ pri
4242
COMPAT_UPSTREAM_SHA1=$(git ls-remote "$NIXPKGS_REPO.git" nixpkgs-26.05-darwin | awk '{print $1}')
4343
update_pkgs_file "$NIXPKGS_COMPAT_PIN_FILE" "$COMPAT_VERSION_SHA1" "$COMPAT_UPSTREAM_SHA1"
4444

45+
# === Update openssl-matrix.nix ===
46+
# When bumping the pin, we want to update the openssl-matrix.nix file to keep the list in sync nixpkgs
47+
# i.e. add newly added release lines, remove newly dropped release lines), and make sure the "openssl"
48+
# attribute still refers to the same release line as the bundled version in deps/openssl/.
49+
50+
OPENSSL_MAJOR=$(awk -F= '/^MAJOR=[0-9]+$/ { print $2; exit }' "$BASE_DIR/deps/openssl/openssl/VERSION.dat")
51+
OPENSSL_MINOR=$(awk -F= '/^MINOR=[0-9]+$/ { print $2; exit }' "$BASE_DIR/deps/openssl/openssl/VERSION.dat")
52+
4553
nix-instantiate -I "nixpkgs=$NIXPKGS_PIN_FILE" --eval --strict --json -E "
4654
let
4755
pkgs = import <nixpkgs> {};
4856
opensslAttrs = builtins.filter
4957
(n: builtins.match \"openssl_[0-9]+(_[0-9]+)?\" n != null)
5058
(builtins.attrNames pkgs);
5159
extraMatrixAttrs = [ \"boringssl\" ];
60+
default = builtins.head (builtins.filter (n:
61+
let
62+
inherit (pkgs.lib) versions;
63+
t = builtins.tryEval pkgs.\${n};
64+
v = if t.success then builtins.tryEval t.value.version else t;
65+
majorVersion = pkgs.lib.optionalString v.success (versions.major v.value);
66+
minorVersion = pkgs.lib.optionalString v.success (versions.minor v.value);
67+
in
68+
majorVersion == ''$OPENSSL_MAJOR'' && minorVersion == ''$OPENSSL_MINOR'') opensslAttrs);
5269
attrs = builtins.filter
5370
(n:
5471
let t = builtins.tryEval pkgs.\${n}; in
55-
t.success && (builtins.tryEval t.value.version).success
72+
n != default && t.success && (builtins.tryEval t.value.version).success
5673
)
5774
(opensslAttrs ++ extraMatrixAttrs);
5875
in
5976
{
60-
inherit attrs;
77+
inherit attrs default;
6178
permittedInsecurePackages = builtins.map (attr: pkgs.\${attr}.name) (
6279
builtins.filter (attr: (pkgs.\${attr}.meta.insecure)) attrs
6380
);
@@ -69,6 +86,10 @@ nix-instantiate -I "nixpkgs=$NIXPKGS_PIN_FILE" --eval --strict --json -E "
6986
}:
7087
7188
{
89+
# "default" OpenSSL release line, should be kept in sync with the bundled version:
90+
openssl = pkgs.\(.default);
91+
92+
# Other OpenSSL variants we want to test for:
7293
inherit (pkgs)
7394
\(.attrs | sort | join("\n "))
7495
;

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)