@@ -1,144 +0,0 @@
1−{ lib, stdenv, fetchurl, nspr, perl, zlib, sqlite, fixDarwinDylibNames, buildPackages }:
2−
3−let
4− nssPEM = fetchurl {
5− url = "http://dev.gentoo.org/~polynomial-c/mozilla/nss-3.15.4-pem-support-20140109.patch.xz";
6− sha256 = "10ibz6y0hknac15zr6dw4gv9nb5r5z9ym6gq18j3xqx7v7n3vpdw";
7− };
8− version = "3.44.4";
9− underscoreVersion = builtins.replaceStrings ["."] ["_"] version;
10−
11−in stdenv.mkDerivation rec {
12− pname = "nss";
13− inherit version;
14−
15− src = fetchurl {
16− url = "mirror://mozilla/security/nss/releases/NSS_${underscoreVersion}_RTM/src/${pname}-${version}.tar.gz";
17− sha256 = "7ec1a52e20fd9a23e1907eeba8f4f2ecd619dac5d20fa023ec5b4faa1843e847";
18− };
19−
20− depsBuildBuild = [ buildPackages.stdenv.cc ];
21−
22− nativeBuildInputs = [ perl ]
23− ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
24−
25− buildInputs = [ zlib sqlite ];
26−
27− propagatedBuildInputs = [ nspr ];
28−
29− prePatch = ''
30− xz -d < ${nssPEM} | patch -p1
31− '';
32−
33− patches =
34− [
35− # Based on http://patch-tracker.debian.org/patch/series/dl/nss/2:3.15.4-1/85_security_load.patch
36− ./85_security_load-3.44.patch
37− ./ckpem.patch
38− ];
39−
40− patchFlags = [ "-p0" ];
41−
42− postPatch = lib.optionalString stdenv.isDarwin ''
43− substituteInPlace nss/coreconf/Darwin.mk --replace '@executable_path/$(notdir $@)' "$out/lib/\$(notdir \$@)"
44− '';
45−
46− outputs = [ "out" "dev" "tools" ];
47−
48− preConfigure = "cd nss";
49−
50− makeFlags = let
51− # NSS's build systems expects aarch32 to be called arm; if we pass in armv6l/armv7l, it
52− # fails with a linker error
53− cpu = if stdenv.hostPlatform.isAarch32 then "arm" else stdenv.hostPlatform.parsed.cpu.name;
54− in [
55− "NSPR_INCLUDE_DIR=${nspr.dev}/include"
56− "NSPR_LIB_DIR=${nspr.out}/lib"
57− "NSDISTMODE=copy"
58− "BUILD_OPT=1"
59− "SOURCE_PREFIX=\$(out)"
60− "NSS_ENABLE_ECC=1"
61− "USE_SYSTEM_ZLIB=1"
62− "NSS_USE_SYSTEM_SQLITE=1"
63− "NATIVE_CC=${buildPackages.stdenv.cc}/bin/cc"
64− ] ++ lib.optionals (!stdenv.isDarwin) [
65− # Pass in CPU even if we're not cross compiling, because otherwise it tries to guess with
66− # uname, which can be wrong if e.g. we're compiling for aarch32 on aarch64
67− "OS_TEST=${cpu}"
68− "CPU_ARCH=${cpu}"
69− ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
70− "CROSS_COMPILE=1"
71− "NSS_DISABLE_GTESTS=1" # don't want to build tests when cross-compiling
72− ] ++ lib.optional stdenv.is64bit "USE_64=1"
73− ++ lib.optional stdenv.isDarwin "CCC=clang++";
74−
75− NIX_CFLAGS_COMPILE = "-Wno-error";
76−
77− # TODO(@oxij): investigate this: `make -n check` works but `make
78− # check` fails with "no rule", same for "installcheck".
79− doCheck = false;
80− doInstallCheck = false;
81−
82− postInstall = ''
83− rm -rf $out/private
84− mv $out/public $out/include
85− mv $out/*.OBJ/* $out/
86− rmdir $out/*.OBJ
87−
88− ln -s lib $out/lib64
89−
90− # Upstream issue: https://bugzilla.mozilla.org/show_bug.cgi?id=530672
91− # https://gitweb.gentoo.org/repo/gentoo.git/plain/dev-libs/nss/files/nss-3.32-gentoo-fixups.patch?id=af1acce6c6d2c3adb17689261dfe2c2b6771ab8a
92− NSS_MAJOR_VERSION=`grep "NSS_VMAJOR" lib/nss/nss.h | awk '{print $3}'`
93− NSS_MINOR_VERSION=`grep "NSS_VMINOR" lib/nss/nss.h | awk '{print $3}'`
94− NSS_PATCH_VERSION=`grep "NSS_VPATCH" lib/nss/nss.h | awk '{print $3}'`
95− PREFIX="$out"
96−
97− mkdir -p $out/lib/pkgconfig
98− sed -e "s,%prefix%,$PREFIX," \
99− -e "s,%exec_prefix%,$PREFIX," \
100− -e "s,%libdir%,$PREFIX/lib64," \
101− -e "s,%includedir%,$dev/include/nss," \
102− -e "s,%NSS_VERSION%,$NSS_MAJOR_VERSION.$NSS_MINOR_VERSION.$NSS_PATCH_VERSION,g" \
103− -e "s,%NSPR_VERSION%,4.16,g" \
104− pkg/pkg-config/nss.pc.in > $out/lib/pkgconfig/nss.pc
105− chmod 0644 $out/lib/pkgconfig/nss.pc
106−
107− sed -e "s,@prefix@,$PREFIX," \
108− -e "s,@MOD_MAJOR_VERSION@,$NSS_MAJOR_VERSION," \
109− -e "s,@MOD_MINOR_VERSION@,$NSS_MINOR_VERSION," \
110− -e "s,@MOD_PATCH_VERSION@,$NSS_PATCH_VERSION," \
111− pkg/pkg-config/nss-config.in > $out/bin/nss-config
112− chmod 0755 $out/bin/nss-config
113− '';
114−
115− postFixup = let
116− isCross = stdenv.hostPlatform != stdenv.buildPlatform;
117− nss = if isCross then buildPackages.nss.tools else "$out";
118− in ''
119− for libname in freebl3 nssdbm3 softokn3
120− do '' +
121− (if stdenv.isDarwin
122− then ''
123− libfile="$out/lib/lib$libname.dylib"
124− DYLD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \
125− '' else ''
126− libfile="$out/lib/lib$libname.so"
127− LD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \
128− '') + ''
129− ${nss}/bin/shlibsign -v -i "$libfile"
130− done
131−
132− moveToOutput bin "$tools"
133− moveToOutput bin/nss-config "$dev"
134− moveToOutput lib/libcrmf.a "$dev" # needed by firefox, for example
135− rm -f "$out"/lib/*.a
136− '';
137−
138− meta = with lib; {
139− homepage = "https://developer.mozilla.org/en-US/docs/NSS";
140− description = "A set of libraries for development of security-enabled client and server applications";
141− license = licenses.mpl20;
142− platforms = platforms.all;
143− };
144−}