nss: make reproducible (#102156)

According to
c1fad130dc/build.sh (l129)
the FIPS mode is not enabled by default. Yet we generate the .chk files
that are only meant to be used for that mode. I have a sense that those
have been cargo-culted around.

Adding FIPS is still possible but you have to explictily build the lib
with `pkgs.nss.override { enableFIPS = true; }`

More info on what FIPS is:
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Tech_Notes/nss_tech_note6

Other distros wrangling with the same issue:
https://bugzilla.opensuse.org/show_bug.cgi?id=1081723
This commit is contained in:
zimbatm 2020-10-31 21:17:26 +01:00 committed by GitHub
parent 6a1782986d
commit 8f2be9ac36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,8 @@
{ stdenv, fetchurl, nspr, perl, zlib, sqlite, darwin, fixDarwinDylibNames, buildPackages, ninja }:
{ stdenv, fetchurl, nspr, perl, zlib, sqlite, darwin, fixDarwinDylibNames, buildPackages, ninja
, # allow FIPS mode. Note that this makes the output non-reproducible.
# https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Tech_Notes/nss_tech_note6
enableFIPS ? false
}:
let
nssPEM = fetchurl {
@ -83,6 +87,7 @@ in stdenv.mkDerivation rec {
-Dhost_arch=${host} \
-Duse_system_zlib=1 \
--enable-libpkix \
${stdenv.lib.optionalString enableFIPS "--enable-fips"} \
${stdenv.lib.optionalString stdenv.isDarwin "--clang"} \
${stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-tests"}
@ -128,7 +133,8 @@ in stdenv.mkDerivation rec {
postFixup = let
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
nss = if isCross then buildPackages.nss.tools else "$out";
in ''
in
(stdenv.lib.optionalString enableFIPS ''
for libname in freebl3 nssdbm3 softokn3
do '' +
(if stdenv.isDarwin
@ -141,7 +147,8 @@ in stdenv.mkDerivation rec {
'') + ''
${nss}/bin/shlibsign -v -i "$libfile"
done
'') +
''
moveToOutput bin "$tools"
moveToOutput bin/nss-config "$dev"
moveToOutput lib/libcrmf.a "$dev" # needed by firefox, for example