Skip to content

Commit 71ac33e

Browse files
authored
tools: refactor shell.nix pkcs11 integration to its own section
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #65404 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3bee1ae commit 71ac33e

1 file changed

Lines changed: 43 additions & 40 deletions

File tree

shell.nix

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ let
5555
useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps;
5656
needsRustCompiler = withTemporal && !useSharedTemporal;
5757

58-
usePkcs11 = pkcs11 != false && pkcs11 != null;
59-
pkcs11Fixture =
60-
if pkcs11 == true then
61-
import ./tools/nix/pkcs11.nix {
62-
inherit pkgs;
63-
inherit (sharedLibDeps) openssl;
64-
}
65-
else
66-
pkcs11;
67-
6858
nativeBuildInputs =
6959
pkgs.nodejs-slim_latest.nativeBuildInputs
7060
++ pkgs.lib.optionals needsRustCompiler [
@@ -88,35 +78,35 @@ let
8878
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
8979
++ pkgs.lib.optional withPerfetto "--with-perfetto";
9080
in
91-
pkgs.mkShell (
92-
{
93-
inherit nativeBuildInputs;
81+
pkgs.mkShell {
82+
inherit nativeBuildInputs;
9483

95-
buildInputs =
96-
builtins.attrValues sharedLibDeps
97-
++ buildInputs
98-
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
99-
if useSeparateDerivationForV8 == true then
100-
let
101-
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
102-
in
103-
pkgs.callPackage ./tools/nix/v8.nix {
104-
inherit nativeBuildInputs icu;
84+
buildInputs =
85+
builtins.attrValues sharedLibDeps
86+
++ buildInputs
87+
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
88+
if useSeparateDerivationForV8 == true then
89+
let
90+
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
91+
in
92+
pkgs.callPackage ./tools/nix/v8.nix {
93+
inherit nativeBuildInputs icu;
10594

106-
configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
107-
buildInputs = buildInputs ++ [ sharedLibsToMock ];
108-
}
109-
else
110-
useSeparateDerivationForV8
111-
);
95+
configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
96+
buildInputs = buildInputs ++ [ sharedLibsToMock ];
97+
}
98+
else
99+
useSeparateDerivationForV8
100+
);
112101

113-
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;
102+
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;
114103

115-
shellHook = pkgs.lib.optionalString (ccache != null) ''
116-
export CC="${pkgs.lib.getExe ccache} $CC"
117-
export CXX="${pkgs.lib.getExe ccache} $CXX"
118-
'';
104+
shellHook = pkgs.lib.optionalString (ccache != null) ''
105+
export CC="${pkgs.lib.getExe ccache} $CC"
106+
export CXX="${pkgs.lib.getExe ccache} $CXX"
107+
'';
119108

109+
env = {
120110
BUILD_WITH = if (ninja != null) then "ninja" else "make";
121111
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";
122112
CONFIG_FLAGS = builtins.toString (
@@ -154,9 +144,22 @@ pkgs.mkShell (
154144
// pkgs.lib.optionalAttrs (!withSQLite) {
155145
NOSQLITE = "1";
156146
}
157-
// pkgs.lib.optionalAttrs usePkcs11 {
158-
NODE_TEST_PKCS11_OPENSSL_CONF = "${pkcs11Fixture.opensslConf}";
159-
NODE_TEST_PKCS11_PIN = pkcs11Fixture.softhsmDir.pin;
160-
NODE_TEST_PKCS11_SOFTHSM_DIR = "${pkcs11Fixture.softhsmDir}";
161-
}
162-
)
147+
// pkgs.lib.optionalAttrs (pkcs11 != false && pkcs11 != null) (
148+
let
149+
pkcs11' =
150+
if pkcs11 == true then
151+
import ./tools/nix/pkcs11.nix {
152+
inherit pkgs;
153+
# Building pkcs11-provider without a shared OpenSSL is not supported.
154+
inherit (sharedLibDeps) openssl;
155+
}
156+
else
157+
pkcs11;
158+
in
159+
{
160+
NODE_TEST_PKCS11_OPENSSL_CONF = pkcs11'.opensslConf;
161+
NODE_TEST_PKCS11_PIN = pkcs11'.softhsmDir.pin;
162+
NODE_TEST_PKCS11_SOFTHSM_DIR = pkcs11'.softhsmDir;
163+
}
164+
);
165+
}

0 commit comments

Comments
 (0)