2017-03-27 14:33:00 +02:00
|
|
|
{ pname, version, updateScript ? null
|
2018-06-29 20:55:43 +02:00
|
|
|
, src, patches ? [], extraConfigureFlags ? [], extraMakeFlags ? []
|
|
|
|
, overrides ? {}, extraNativeBuildInputs ? [], meta
|
2017-04-01 02:00:00 +02:00
|
|
|
, isTorBrowserLike ? false }:
|
2017-03-27 14:33:00 +02:00
|
|
|
|
2018-06-29 20:55:43 +02:00
|
|
|
{ lib, stdenv, pkgconfig, pango, perl, python2, zip, libIDL
|
2018-02-25 03:23:58 +01:00
|
|
|
, libjpeg, zlib, dbus, dbus-glib, bzip2, xorg
|
2017-03-27 14:33:00 +02:00
|
|
|
, freetype, fontconfig, file, nspr, nss, libnotify
|
2018-02-24 14:12:44 +01:00
|
|
|
, yasm, libGLU_combined, sqlite, unzip, makeWrapper
|
2013-06-11 11:52:15 +02:00
|
|
|
, hunspell, libevent, libstartup_notification, libvpx
|
2018-07-21 02:44:44 +02:00
|
|
|
, icu, libpng, jemalloc, glib
|
2017-09-28 02:13:15 +02:00
|
|
|
, autoconf213, which, gnused, cargo, rustc, llvmPackages
|
2013-10-06 06:07:42 +02:00
|
|
|
, debugBuild ? false
|
2017-03-27 14:33:00 +02:00
|
|
|
|
|
|
|
### optionals
|
|
|
|
|
2017-03-27 14:35:34 +02:00
|
|
|
## optional libraries
|
|
|
|
|
2017-03-27 14:33:00 +02:00
|
|
|
, alsaSupport ? true, alsaLib
|
|
|
|
, pulseaudioSupport ? true, libpulseaudio
|
|
|
|
, ffmpegSupport ? true, gstreamer, gst-plugins-base
|
2017-04-08 02:00:00 +02:00
|
|
|
, gtk3Support ? !isTorBrowserLike, gtk2, gtk3, wrapGAppsHook
|
2017-09-27 15:30:29 +02:00
|
|
|
, gssSupport ? true, kerberos
|
2017-03-27 14:33:00 +02:00
|
|
|
|
2017-03-27 14:35:34 +02:00
|
|
|
## privacy-related options
|
|
|
|
|
2017-04-01 02:00:00 +02:00
|
|
|
, privacySupport ? isTorBrowserLike
|
2017-03-27 14:35:34 +02:00
|
|
|
|
|
|
|
# WARNING: NEVER set any of the options below to `true` by default.
|
|
|
|
# Set to `privacySupport` or `false`.
|
|
|
|
|
2018-05-13 19:19:55 +02:00
|
|
|
# webrtcSupport breaks the aarch64 build on version >= 60.
|
|
|
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=1434589
|
|
|
|
, webrtcSupport ? (if lib.versionAtLeast version "60" && stdenv.isAarch64 then false else !privacySupport)
|
2017-11-15 01:00:00 +01:00
|
|
|
, geolocationSupport ? !privacySupport
|
|
|
|
, googleAPISupport ? geolocationSupport
|
2017-03-27 14:33:00 +02:00
|
|
|
, crashreporterSupport ? false
|
|
|
|
|
2017-11-15 01:00:00 +01:00
|
|
|
, safeBrowsingSupport ? false
|
2017-03-27 14:33:00 +02:00
|
|
|
, drmSupport ? false
|
|
|
|
|
2017-03-27 14:35:34 +02:00
|
|
|
## other
|
|
|
|
|
2018-01-31 17:50:10 +01:00
|
|
|
# As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/31843#issuecomment-346372756 we
|
|
|
|
# have permission to use the official firefox branding.
|
|
|
|
#
|
|
|
|
# Fur purposes of documentation the statement of @sylvestre:
|
|
|
|
# > As the person who did part of the work described in the LWN article
|
|
|
|
# > and release manager working for Mozilla, I can confirm the statement
|
|
|
|
# > that I made in
|
|
|
|
# > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815006
|
|
|
|
# >
|
|
|
|
# > @garbas shared with me the list of patches applied for the Nix package.
|
|
|
|
# > As they are just for portability and tiny modifications, they don't
|
|
|
|
# > alter the experience of the product. In parallel, Rok also shared the
|
|
|
|
# > build options. They seem good (even if I cannot judge the quality of the
|
|
|
|
# > packaging of the underlying dependencies like sqlite, png, etc).
|
|
|
|
# > Therefor, as long as you keep the patch queue sane and you don't alter
|
|
|
|
# > the experience of Firefox users, you won't have any issues using the
|
|
|
|
# > official branding.
|
|
|
|
, enableOfficialBranding ? true
|
2013-06-06 13:07:54 +02:00
|
|
|
}:
|
|
|
|
|
2018-02-01 01:00:00 +01:00
|
|
|
assert stdenv.cc.libc or null != null;
|
2013-06-06 13:07:54 +02:00
|
|
|
|
2015-09-03 10:54:13 +02:00
|
|
|
let
|
2017-03-27 14:33:00 +02:00
|
|
|
flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
|
2017-09-28 02:13:15 +02:00
|
|
|
gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
|
2017-03-27 14:33:00 +02:00
|
|
|
in
|
2013-06-06 13:07:54 +02:00
|
|
|
|
2017-04-01 02:00:00 +02:00
|
|
|
stdenv.mkDerivation (rec {
|
2016-01-10 14:56:17 +01:00
|
|
|
name = "${pname}-unwrapped-${version}";
|
2013-06-06 13:07:54 +02:00
|
|
|
|
2017-03-27 14:33:00 +02:00
|
|
|
inherit src patches meta;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
gtk2 perl zip libIDL libjpeg zlib bzip2
|
2018-07-12 15:05:52 +02:00
|
|
|
dbus dbus-glib pango freetype fontconfig xorg.libXi xorg.libXcursor
|
2017-03-27 14:33:00 +02:00
|
|
|
xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
|
2018-02-24 14:12:44 +01:00
|
|
|
nspr libnotify xorg.pixman yasm libGLU_combined
|
2017-03-27 14:33:00 +02:00
|
|
|
xorg.libXScrnSaver xorg.scrnsaverproto
|
|
|
|
xorg.libXext xorg.xextproto sqlite unzip makeWrapper
|
2018-06-29 20:55:43 +02:00
|
|
|
libevent libstartup_notification libvpx /* cairo */
|
|
|
|
icu libpng jemalloc glib
|
2017-03-27 14:33:00 +02:00
|
|
|
]
|
2017-04-01 02:00:00 +02:00
|
|
|
++ lib.optionals (!isTorBrowserLike) [ nss ]
|
2018-06-29 20:55:43 +02:00
|
|
|
++ lib.optional (lib.versionOlder version "61") hunspell
|
2017-03-27 14:33:00 +02:00
|
|
|
++ lib.optional alsaSupport alsaLib
|
|
|
|
++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
|
|
|
|
++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
|
2017-09-27 15:30:29 +02:00
|
|
|
++ lib.optional gtk3Support gtk3
|
|
|
|
++ lib.optional gssSupport kerberos;
|
2014-07-23 15:31:49 +02:00
|
|
|
|
2018-06-29 20:55:43 +02:00
|
|
|
NIX_CFLAGS_COMPILE = "-I${nspr.dev}/include/nspr -I${nss.dev}/include/nss -I${glib.dev}/include/gio-unix-2.0";
|
2017-09-28 02:13:15 +02:00
|
|
|
|
2017-04-23 04:50:33 +02:00
|
|
|
nativeBuildInputs =
|
2018-06-29 20:55:43 +02:00
|
|
|
[ autoconf213 which gnused pkgconfig perl python2 cargo rustc ]
|
|
|
|
++ lib.optional gtk3Support wrapGAppsHook ++ extraNativeBuildInputs;
|
2017-03-27 14:33:00 +02:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# remove distributed configuration files
|
|
|
|
rm -f configure
|
|
|
|
rm -f js/src/configure
|
|
|
|
rm -f .mozconfig*
|
2018-02-01 01:00:00 +01:00
|
|
|
'' + (if lib.versionAtLeast version "58"
|
|
|
|
# this will run autoconf213
|
|
|
|
then ''
|
|
|
|
configureScript="$(realpath ./mach) configure"
|
|
|
|
'' else ''
|
|
|
|
make -f client.mk configure-files
|
|
|
|
configureScript="$(realpath ./configure)"
|
|
|
|
'') + ''
|
|
|
|
cxxLib=$( echo -n ${gcc}/include/c++/* )
|
|
|
|
archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
|
2017-03-27 14:33:00 +02:00
|
|
|
|
2018-06-29 20:55:43 +02:00
|
|
|
test -f layout/style/ServoBindings.toml && sed -i -e '/"-DRUST_BINDGEN"/ a , "-cxx-isystem", "'$cxxLib'", "-isystem", "'$archLib'"' layout/style/ServoBindings.toml
|
2018-01-31 01:52:10 +01:00
|
|
|
'' + lib.optionalString googleAPISupport ''
|
|
|
|
# Google API key used by Chromium and Firefox.
|
|
|
|
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
|
|
|
|
# please get your own set of keys.
|
|
|
|
echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" > $TMPDIR/ga
|
2018-02-01 13:38:16 +01:00
|
|
|
configureFlagsArray+=("--with-google-api-keyfile=$TMPDIR/ga")
|
2018-02-01 01:00:00 +01:00
|
|
|
'' + lib.optionalString (lib.versionOlder version "58") ''
|
2017-03-27 14:33:00 +02:00
|
|
|
cd obj-*
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--enable-application=browser"
|
|
|
|
"--with-system-jpeg"
|
|
|
|
"--with-system-zlib"
|
|
|
|
"--with-system-bz2"
|
|
|
|
"--with-system-libevent"
|
|
|
|
"--with-system-libvpx"
|
|
|
|
"--with-system-png" # needs APNG support
|
|
|
|
"--with-system-icu"
|
|
|
|
"--enable-system-ffi"
|
|
|
|
"--enable-system-pixman"
|
|
|
|
"--enable-system-sqlite"
|
|
|
|
#"--enable-system-cairo"
|
|
|
|
"--enable-startup-notification"
|
2017-05-14 17:10:06 +02:00
|
|
|
#"--enable-content-sandbox" # TODO: probably enable after 54
|
2017-03-27 14:33:00 +02:00
|
|
|
"--disable-tests"
|
|
|
|
"--disable-necko-wifi" # maybe we want to enable this at some point
|
|
|
|
"--disable-updater"
|
|
|
|
"--enable-jemalloc"
|
|
|
|
"--disable-maintenance-service"
|
|
|
|
"--disable-gconf"
|
|
|
|
"--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
|
|
|
|
]
|
2018-06-29 20:55:43 +02:00
|
|
|
++ lib.optional (lib.versionOlder version "61") "--enable-system-hunspell"
|
2018-02-01 01:00:00 +01:00
|
|
|
++ lib.optionals (lib.versionAtLeast version "56" && !stdenv.hostPlatform.isi686) [
|
2017-10-14 21:23:16 +02:00
|
|
|
# on i686-linux: --with-libclang-path is not available in this configuration
|
2018-01-16 22:19:02 +01:00
|
|
|
"--with-libclang-path=${llvmPackages.libclang}/lib"
|
2017-09-28 02:13:15 +02:00
|
|
|
"--with-clang-path=${llvmPackages.clang}/bin/clang"
|
|
|
|
]
|
2018-02-01 01:00:00 +01:00
|
|
|
++ lib.optionals (lib.versionAtLeast version "57") [
|
2017-12-09 17:40:57 +01:00
|
|
|
"--enable-webrender=build"
|
|
|
|
]
|
2017-04-01 02:00:00 +02:00
|
|
|
|
|
|
|
# TorBrowser patches these
|
|
|
|
++ lib.optionals (!isTorBrowserLike) [
|
|
|
|
"--with-system-nss"
|
|
|
|
"--with-system-nspr"
|
|
|
|
]
|
|
|
|
|
|
|
|
# and wants these
|
2017-11-15 01:00:00 +01:00
|
|
|
++ lib.optionals isTorBrowserLike ([
|
2017-04-01 02:00:00 +02:00
|
|
|
"--with-tor-browser-version=${version}"
|
|
|
|
"--enable-signmar"
|
|
|
|
"--enable-verify-mar"
|
|
|
|
|
|
|
|
# We opt out of TorBrowser's nspr because that patch is useless on
|
|
|
|
# anything but Windows and produces zero fingerprinting
|
|
|
|
# possibilities on other platforms.
|
|
|
|
# Lets save some space instead.
|
|
|
|
"--with-system-nspr"
|
2017-11-15 01:00:00 +01:00
|
|
|
] ++ flag geolocationSupport "mozril-geoloc"
|
|
|
|
++ flag safeBrowsingSupport "safe-browsing"
|
|
|
|
)
|
2017-04-01 02:00:00 +02:00
|
|
|
|
2017-03-27 14:33:00 +02:00
|
|
|
++ flag alsaSupport "alsa"
|
|
|
|
++ flag pulseaudioSupport "pulseaudio"
|
|
|
|
++ flag ffmpegSupport "ffmpeg"
|
2017-09-27 15:30:29 +02:00
|
|
|
++ flag gssSupport "negotiateauth"
|
2017-03-27 14:33:00 +02:00
|
|
|
++ lib.optional (!ffmpegSupport) "--disable-gstreamer"
|
|
|
|
++ flag webrtcSupport "webrtc"
|
|
|
|
++ flag crashreporterSupport "crashreporter"
|
2017-07-01 05:06:51 +02:00
|
|
|
++ lib.optional drmSupport "--enable-eme=widevine"
|
2017-03-27 14:33:00 +02:00
|
|
|
|
|
|
|
++ (if debugBuild then [ "--enable-debug" "--enable-profiling" ]
|
|
|
|
else [ "--disable-debug" "--enable-release"
|
|
|
|
"--enable-optimize"
|
|
|
|
"--enable-strip" ])
|
2017-08-15 02:00:00 +02:00
|
|
|
++ lib.optional enableOfficialBranding "--enable-official-branding"
|
|
|
|
++ extraConfigureFlags;
|
2014-07-23 15:31:49 +02:00
|
|
|
|
2018-02-01 01:00:00 +01:00
|
|
|
# Before 58 we have to run `make -f client.mk configure-files` at
|
|
|
|
# the top level, and then run `./configure` in the obj-* dir (see
|
|
|
|
# above), but in 58 we have to instead run `./mach configure` at the
|
|
|
|
# top level and then run `make` in obj-*. (We can also run the
|
|
|
|
# `make` at the top level in 58, but then we would have to `cd` to
|
|
|
|
# `make install` anyway. This is ugly, but simple.)
|
|
|
|
postConfigure = lib.optionalString (lib.versionAtLeast version "58") ''
|
|
|
|
cd obj-*
|
|
|
|
'';
|
|
|
|
|
2017-08-15 02:00:00 +02:00
|
|
|
preBuild = lib.optionalString (enableOfficialBranding && isTorBrowserLike) ''
|
|
|
|
buildFlagsArray=("MOZ_APP_DISPLAYNAME=Tor Browser")
|
|
|
|
'';
|
|
|
|
|
|
|
|
makeFlags = lib.optionals enableOfficialBranding [
|
|
|
|
"MOZILLA_OFFICIAL=1"
|
|
|
|
"BUILD_OFFICIAL=1"
|
|
|
|
]
|
|
|
|
++ extraMakeFlags;
|
|
|
|
|
2014-07-23 15:31:49 +02:00
|
|
|
enableParallelBuilding = true;
|
2018-04-25 05:20:18 +02:00
|
|
|
doCheck = false; # "--disable-tests" above
|
2014-07-23 15:31:49 +02:00
|
|
|
|
2017-03-27 14:33:00 +02:00
|
|
|
preInstall = ''
|
|
|
|
# The following is needed for startup cache creation on grsecurity kernels.
|
|
|
|
paxmark m dist/bin/xpcshell
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# For grsecurity kernels
|
2018-03-14 13:02:24 +01:00
|
|
|
paxmark m $out/lib/firefox*/{firefox,firefox-bin,plugin-container}
|
2017-03-27 14:33:00 +02:00
|
|
|
|
|
|
|
# Remove SDK cruft. FIXME: move to a separate output?
|
|
|
|
rm -rf $out/share/idl $out/include $out/lib/firefox-devel-*
|
|
|
|
|
|
|
|
# Needed to find Mozilla runtime
|
|
|
|
gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
2016-09-18 23:19:51 +02:00
|
|
|
# Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
|
2017-03-27 14:33:00 +02:00
|
|
|
patchelf --set-rpath "${lib.getLib libnotify
|
2018-03-14 13:02:24 +01:00
|
|
|
}/lib:$(patchelf --print-rpath "$out"/lib/firefox*/libxul.so)" \
|
|
|
|
"$out"/lib/firefox*/libxul.so
|
2017-03-27 14:33:00 +02:00
|
|
|
'';
|
2016-09-18 23:19:51 +02:00
|
|
|
|
2017-04-09 19:17:40 +02:00
|
|
|
doInstallCheck = true;
|
2017-03-27 14:33:00 +02:00
|
|
|
installCheckPhase = ''
|
|
|
|
# Some basic testing
|
|
|
|
"$out/bin/firefox" --version
|
|
|
|
'';
|
2013-06-06 13:07:54 +02:00
|
|
|
|
2014-07-23 15:31:49 +02:00
|
|
|
passthru = {
|
2016-05-18 23:07:49 +02:00
|
|
|
browserName = "firefox";
|
2017-03-27 14:33:00 +02:00
|
|
|
inherit version updateScript;
|
|
|
|
isFirefox3Like = true;
|
2017-04-01 02:00:00 +02:00
|
|
|
inherit isTorBrowserLike;
|
2017-03-27 14:33:00 +02:00
|
|
|
gtk = gtk2;
|
|
|
|
inherit nspr;
|
|
|
|
inherit ffmpegSupport;
|
2017-09-27 15:30:29 +02:00
|
|
|
inherit gssSupport;
|
2017-05-04 22:09:15 +02:00
|
|
|
} // lib.optionalAttrs gtk3Support { inherit gtk3; };
|
2017-04-01 02:00:00 +02:00
|
|
|
|
|
|
|
} // overrides)
|