aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/libraries/nss/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/nss/default.nix')
-rw-r--r--nixpkgs/pkgs/development/libraries/nss/default.nix92
1 files changed, 54 insertions, 38 deletions
diff --git a/nixpkgs/pkgs/development/libraries/nss/default.nix b/nixpkgs/pkgs/development/libraries/nss/default.nix
index d48b5a6ba73..e378cd5554c 100644
--- a/nixpkgs/pkgs/development/libraries/nss/default.nix
+++ b/nixpkgs/pkgs/development/libraries/nss/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, fetchurl, nspr, perl, zlib, sqlite, fixDarwinDylibNames, buildPackages }:
+{ stdenv, fetchurl, nspr, perl, zlib, sqlite, darwin, fixDarwinDylibNames, buildPackages, ninja }:
let
nssPEM = fetchurl {
url = "http://dev.gentoo.org/~polynomial-c/mozilla/nss-3.15.4-pem-support-20140109.patch.xz";
sha256 = "10ibz6y0hknac15zr6dw4gv9nb5r5z9ym6gq18j3xqx7v7n3vpdw";
};
- version = "3.52";
+ version = "3.56";
underscoreVersion = builtins.replaceStrings ["."] ["_"] version;
in stdenv.mkDerivation rec {
@@ -14,12 +14,13 @@ in stdenv.mkDerivation rec {
src = fetchurl {
url = "mirror://mozilla/security/nss/releases/NSS_${underscoreVersion}_RTM/src/${pname}-${version}.tar.gz";
- sha256 = "0q8m9jf6zgkbhx71myjb7y0gcl5ib3gj6qkl9yvdqpd6vl6fn2ha";
+ sha256 = "174f0ki2f8szkgv02jlsg2ci332sl9dabr2vcwnyjp1vxplf0xgq";
};
depsBuildBuild = [ buildPackages.stdenv.cc ];
- nativeBuildInputs = [ perl ];
+ nativeBuildInputs = [ perl ninja (buildPackages.python3.withPackages (ps: with ps; [ gyp ])) ]
+ ++ stdenv.lib.optional stdenv.isDarwin darwin.cctools;
buildInputs = [ zlib sqlite ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
@@ -29,10 +30,18 @@ in stdenv.mkDerivation rec {
prePatch = ''
# strip the trailing whitespace from the patch line and the renamed CKO_NETSCAPE_ enum to CKO_NSS_
xz -d < ${nssPEM} | sed \
- -e '/^-DIRS = builtins $/ s/ $//' \
+ -e 's/-DIRS = builtins $/-DIRS = . builtins/g' \
-e 's/CKO_NETSCAPE_/CKO_NSS_/g' \
-e 's/CKT_NETSCAPE_/CKT_NSS_/g' \
| patch -p1
+
+ patchShebangs nss
+
+ for f in nss/coreconf/config.gypi nss/build.sh nss/coreconf/config.gypi; do
+ substituteInPlace "$f" --replace "/usr/bin/env" "${buildPackages.coreutils}/bin/env"
+ done
+
+ substituteInPlace nss/coreconf/config.gypi --replace "/usr/bin/grep" "${buildPackages.coreutils}/bin/env grep"
'';
patches =
@@ -40,50 +49,55 @@ in stdenv.mkDerivation rec {
# Based on http://patch-tracker.debian.org/patch/series/dl/nss/2:3.15.4-1/85_security_load.patch
./85_security_load.patch
./ckpem.patch
+ ./fix-cross-compilation.patch
];
patchFlags = [ "-p0" ];
- postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
- substituteInPlace nss/coreconf/Darwin.mk --replace '@executable_path/$(notdir $@)' "$out/lib/\$(notdir \$@)"
- '';
+ postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
+ substituteInPlace nss/coreconf/Darwin.mk --replace '@executable_path/$(notdir $@)' "$out/lib/\$(notdir \$@)"
+ substituteInPlace nss/coreconf/config.gypi --replace "'DYLIB_INSTALL_NAME_BASE': '@executable_path'" "'DYLIB_INSTALL_NAME_BASE': '$out/lib'"
+ '';
outputs = [ "out" "dev" "tools" ];
preConfigure = "cd nss";
- makeFlags = let
- cpu = stdenv.hostPlatform.parsed.cpu.name;
- in [
- "NSPR_INCLUDE_DIR=${nspr.dev}/include"
- "NSPR_LIB_DIR=${nspr.out}/lib"
- "NSDISTMODE=copy"
- "BUILD_OPT=1"
- "SOURCE_PREFIX=\$(out)"
- "NSS_ENABLE_ECC=1"
- "USE_SYSTEM_ZLIB=1"
- "NSS_USE_SYSTEM_SQLITE=1"
- "NATIVE_CC=${buildPackages.stdenv.cc}/bin/cc"
- ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
- "OS_TEST=${cpu}"
- "CPU_ARCH=${cpu}"
- "CROSS_COMPILE=1"
- "NSS_DISABLE_GTESTS=1" # don't want to build tests when cross-compiling
- ] ++ stdenv.lib.optional stdenv.is64bit "USE_64=1"
- ++ stdenv.lib.optional stdenv.isDarwin "CCC=clang++";
-
- NIX_CFLAGS_COMPILE = "-Wno-error";
-
- # TODO(@oxij): investigate this: `make -n check` works but `make
- # check` fails with "no rule", same for "installcheck".
- doCheck = false;
- doInstallCheck = false;
-
- postInstall = ''
+ buildPhase = let
+ getArch = platform: if platform.isx86_64 then "x64"
+ else if platform.isx86_32 then "ia32"
+ else if platform.isAarch32 then "arm"
+ else if platform.isAarch64 then "arm64"
+ else platform.parsed.cpu.name;
+ # yes, this is correct. nixpkgs uses "host" for the platform the binary will run on whereas nss uses "host" for the platform that the build is running on
+ target = getArch stdenv.hostPlatform;
+ host = getArch stdenv.buildPlatform;
+ in ''
+ runHook preBuild
+
+ sed -i 's|nss_dist_dir="$dist_dir"|nss_dist_dir="'$out'"|;s|nss_dist_obj_dir="$obj_dir"|nss_dist_obj_dir="'$out'"|' build.sh
+ ./build.sh -v --opt \
+ --with-nspr=${nspr.dev}/include:${nspr.out}/lib \
+ --system-sqlite \
+ --enable-legacy-db \
+ --target ${target} \
+ -Dhost_arch=${host} \
+ -Duse_system_zlib=1 \
+ --enable-libpkix \
+ ${stdenv.lib.optionalString stdenv.isDarwin "--clang"} \
+ ${stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-tests"}
+
+ runHook postBuild
+ '';
+
+ NIX_CFLAGS_COMPILE = "-Wno-error -DNIX_NSS_LIBDIR=\"${placeholder "out"}/lib/\"";
+
+ installPhase = ''
+ runHook preInstall
+
rm -rf $out/private
+ find $out -name "*.TOC" -delete
mv $out/public $out/include
- mv $out/*.OBJ/* $out/
- rmdir $out/*.OBJ
ln -s lib $out/lib64
@@ -133,6 +147,8 @@ in stdenv.mkDerivation rec {
moveToOutput bin/nss-config "$dev"
moveToOutput lib/libcrmf.a "$dev" # needed by firefox, for example
rm -f "$out"/lib/*.a
+
+ runHook postInstall
'';
meta = with stdenv.lib; {