Merge pull request #44186 from matthewbauer/firefox

Firefox on Darwin
This commit is contained in:
Matthew Bauer 2018-08-11 22:56:04 -05:00 committed by GitHub
commit 98df4f6351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 136 additions and 67 deletions

View File

@ -174,6 +174,7 @@ stdenv.mkDerivation {
gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
'';
passthru.execdir = "/bin";
passthru.ffmpegSupport = true;
passthru.gssSupport = true;
# update with:

View File

@ -16,7 +16,7 @@
## optional libraries
, alsaSupport ? true, alsaLib
, alsaSupport ? stdenv.isLinux, alsaLib
, pulseaudioSupport ? true, libpulseaudio
, ffmpegSupport ? true, gstreamer, gst-plugins-base
, gtk3Support ? !isTorBrowserLike, gtk2, gtk3, wrapGAppsHook
@ -39,6 +39,10 @@
, safeBrowsingSupport ? false
, drmSupport ? false
# macOS dependencies
, xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox
, CoreLocation, Foundation, AddressBook, libobjc, cups, rsync
## other
# As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at
@ -66,7 +70,14 @@ assert stdenv.cc.libc or null != null;
let
flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
default-toolkit = if stdenv.isDarwin then "cairo-cocoa"
else "cairo-gtk${if gtk3Support then "3" else "2"}";
execdir = if stdenv.isDarwin
then "/Applications/${browserName}.app/Contents/MacOS"
else "/bin";
browserName = if stdenv.isDarwin then "Firefox" else "firefox";
in
stdenv.mkDerivation (rec {
@ -90,13 +101,27 @@ stdenv.mkDerivation (rec {
++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
++ lib.optional gtk3Support gtk3
++ lib.optional gssSupport kerberos;
++ lib.optional gssSupport kerberos
++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
AVFoundation MediaToolbox CoreLocation
Foundation libobjc AddressBook cups ];
NIX_CFLAGS_COMPILE = "-I${nspr.dev}/include/nspr -I${nss.dev}/include/nss -I${glib.dev}/include/gio-unix-2.0";
NIX_CFLAGS_COMPILE = [ "-I${nspr.dev}/include/nspr"
"-I${nss.dev}/include/nss"
"-I${glib.dev}/include/gio-unix-2.0" ]
++ lib.optional stdenv.isDarwin [
"-isystem ${llvmPackages.libcxx}/include/c++/v1"
"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10" ];
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace js/src/jsmath.cpp --replace 'defined(HAVE___SINCOS)' 0
'';
nativeBuildInputs =
[ autoconf213 which gnused pkgconfig perl python2 cargo rustc ]
++ lib.optional gtk3Support wrapGAppsHook ++ extraNativeBuildInputs;
++ lib.optional gtk3Support wrapGAppsHook
++ lib.optionals stdenv.isDarwin [ xcbuild rsync ]
++ extraNativeBuildInputs;
preConfigure = ''
# remove distributed configuration files
@ -111,10 +136,22 @@ stdenv.mkDerivation (rec {
make -f client.mk configure-files
configureScript="$(realpath ./configure)"
'') + ''
cxxLib=$( echo -n ${gcc}/include/c++/* )
archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
export MOZCONFIG=$(pwd)/mozconfig
test -f layout/style/ServoBindings.toml && sed -i -e '/"-DRUST_BINDGEN"/ a , "-cxx-isystem", "'$cxxLib'", "-isystem", "'$archLib'"' layout/style/ServoBindings.toml
# Set C flags for Rust's bindgen program. Unlike ordinary C
# compilation, bindgen does not invoke $CC directly. Instead it
# uses LLVM's libclang. To make sure all necessary flags are
# included we need to look in a few places.
# TODO: generalize this process for other use-cases.
BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-cflags) \
$(< ${stdenv.cc}/nix-support/cc-cflags) \
${stdenv.cc.default_cxx_stdlib_compile} \
${lib.optionalString stdenv.cc.isClang "-idirafter ${stdenv.cc.cc}/lib/clang/${lib.getVersion stdenv.cc.cc}/include"} \
${lib.optionalString stdenv.cc.isGNU "-isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc} -isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc}/$(cc -dumpmachine)"} \
$NIX_CFLAGS_COMPILE"
echo "ac_add_options BINDGEN_CFLAGS='$BINDGEN_CFLAGS'" >> $MOZCONFIG
'' + lib.optionalString googleAPISupport ''
# Google API key used by Chromium and Firefox.
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
@ -146,7 +183,8 @@ stdenv.mkDerivation (rec {
"--enable-jemalloc"
"--disable-maintenance-service"
"--disable-gconf"
"--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
"--enable-default-toolkit=${default-toolkit}"
"--disable-xcode-checks"
]
++ lib.optional (lib.versionOlder version "61") "--enable-system-hunspell"
++ lib.optionals (lib.versionAtLeast version "56" && !stdenv.hostPlatform.isi686) [
@ -223,7 +261,12 @@ stdenv.mkDerivation (rec {
paxmark m dist/bin/xpcshell
'';
postInstall = ''
installPhase = if stdenv.isDarwin then ''
mkdir -p $out/Applications
cp -LR dist/Firefox.app $out/Applications
'' else null;
postInstall = lib.optionalString stdenv.isLinux ''
# For grsecurity kernels
paxmark m $out/lib/firefox*/{firefox,firefox-bin,plugin-container}
@ -234,7 +277,7 @@ stdenv.mkDerivation (rec {
gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
'';
postFixup = ''
postFixup = lib.optionalString stdenv.isLinux ''
# Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
patchelf --set-rpath "${lib.getLib libnotify
}/lib:$(patchelf --print-rpath "$out"/lib/firefox*/libxul.so)" \
@ -244,11 +287,10 @@ stdenv.mkDerivation (rec {
doInstallCheck = true;
installCheckPhase = ''
# Some basic testing
"$out/bin/firefox" --version
"$out${execdir}/${browserName}" --version
'';
passthru = {
browserName = "firefox";
inherit version updateScript;
isFirefox3Like = true;
inherit isTorBrowserLike;
@ -256,6 +298,8 @@ stdenv.mkDerivation (rec {
inherit nspr;
inherit ffmpegSupport;
inherit gssSupport;
inherit execdir;
inherit browserName;
} // lib.optionalAttrs gtk3Support { inherit gtk3; };
} // overrides)

View File

@ -36,7 +36,7 @@ rec {
description = "A web browser built from Firefox source tree";
homepage = http://www.mozilla.com/en-US/firefox/;
maintainers = with lib.maintainers; [ eelco ];
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
updateScript = callPackage ./update.nix {
attrPath = "firefox-unwrapped";

View File

@ -98,24 +98,28 @@ let
];
};
buildInputs = [makeWrapper]
++ lib.optional (browser ? gtk3) browser.gtk3;
nativeBuildInputs = [ makeWrapper lndir ];
buildInputs = lib.optional (browser ? gtk3) browser.gtk3;
buildCommand = ''
if [ ! -x "${browser}/bin/${browserName}" ]
buildCommand = lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications
cp -R --no-preserve=mode,ownership ${browser}/Applications/${browserName}.app $out/Applications
rm -f $out${browser.execdir}/${browserName}
'' + ''
if [ ! -x "${browser}${browser.execdir}/${browserName}" ]
then
echo "cannot find executable file \`${browser}/bin/${browserName}'"
echo "cannot find executable file \`${browser}${browser.execdir}/${browserName}'"
exit 1
fi
makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")" \
"$out/bin/${browserName}${nameSuffix}" \
makeWrapper "$(readlink -v --canonicalize-existing "${browser}${browser.execdir}/${browserName}")" \
"$out${browser.execdir}/${browserName}${nameSuffix}" \
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
--suffix LD_LIBRARY_PATH ':' "$libs" \
--suffix-each GTK_PATH ':' "$gtk_modules" \
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
--prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))" \
--suffix PATH ':' "$out/bin" \
--suffix PATH ':' "$out${browser.execdir}" \
--set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}" \
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
${lib.optionalString (browser ? gtk3)
@ -141,7 +145,7 @@ let
mkdir -p $out/lib/mozilla
for ext in ${toString nativeMessagingHosts}; do
${lndir}/bin/lndir -silent $ext/lib/mozilla $out/lib/mozilla
lndir -silent $ext/lib/mozilla $out/lib/mozilla
done
# For manpages, in case the program supplies them

View File

@ -337,6 +337,7 @@ stdenv.mkDerivation rec {
$out/bin/tor-browser -version >/dev/null
'';
passthru.execdir = "/bin";
meta = with stdenv.lib; {
description = "An unofficial version of the tor browser bundle, built from source";
homepage = https://torproject.org/;

View File

@ -294,8 +294,7 @@ runCommand "Platforms" {} ''
install -D ${writeText "PackageTypes.xcspec" (toPlist {} PackageTypes)} $platform/Developer/Library/Xcode/Specifications/PackageTypes.xcspec
install -D ${writeText "ProductTypes.xcspec" (toPlist {} ProductTypes)} $platform/Developer/Library/Xcode/Specifications/ProductTypes.xcspec
# per-platform bins go here
mkdir -p $platform/usr/bin
ln -s $platform $platform/usr
mkdir -p $platform/Developer
ln -s ${sdks} $platform/Developer/SDKs

View File

@ -1,4 +1,5 @@
{ runCommand, lib, toolchainName, sdkName, writeText, version, xcodePlatform }:
{ stdenv, runCommand, lib, toolchainName, sdkName
, writeText, version, xcodePlatform, libcxx, symlinkJoin }:
let
inherit (lib.generators) toPlist;
@ -18,11 +19,11 @@ let
};
in
runCommand "SDKs" {
inherit version;
} ''
runCommand "SDKs" {} ''
sdk=$out/${sdkName}.sdk
install -D ${writeText "SDKSettings.plist" (toPlist {} SDKSettings)} $sdk/SDKSettings.plist
install -D ${writeText "SystemVersion.plist" (toPlist {} SystemVersion)} $sdk/System/Library/CoreServices/SystemVersion.plist
ln -s $sdk $sdk/usr
ln -s $sdk $out/${xcodePlatform}.sdk
''

View File

@ -1,4 +1,4 @@
{ runCommand, toolchainName, fetchurl, makeWrapper, stdenv
{ runCommand, toolchainName, fetchurl, stdenv
, buildPackages, lib, writeText }:
let
@ -20,52 +20,52 @@ let
};
in
runCommand "Toolchains" {
nativeBuildInputs = [ makeWrapper ];
} (''
runCommand "Toolchains" {} (''
toolchain=$out/XcodeDefault.xctoolchain
mkdir -p $toolchain
install -D ${writeText "ToolchainInfo.plist" (toPlist {} ToolchainInfo)} $toolchain/ToolchainInfo.plist
mkdir -p $toolchain/usr/include
mkdir -p $toolchain/usr/lib
mkdir -p $toolchain/usr/libexec
mkdir -p $toolchain/usr/share
mkdir -p $toolchain/usr/bin
ln -s $toolchain $toolchain/usr
mkdir -p $toolchain/include
mkdir -p $toolchain/lib
mkdir -p $toolchain/libexec
mkdir -p $toolchain/share
mkdir -p $toolchain/bin
for bin in ${getBin stdenv.cc}/bin/*; do
ln -s $bin $toolchain/usr/bin
ln -s $bin $toolchain/bin
done
for bin in ${getBin stdenv.cc.bintools.bintools}/bin/*; do
if ! [ -e "$toolchain/usr/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/usr/bin
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.yacc}/bin/yacc $toolchain/usr/bin/yacc
ln -s ${buildPackages.yacc}/bin/bison $toolchain/usr/bin/bison
ln -s ${buildPackages.flex}/bin/flex $toolchain/usr/bin/flex
ln -s ${buildPackages.flex}/bin/flex++ $toolchain/usr/bin/flex++
ln -s $toolchain/bin/flex $toolchain/usr/bin/lex
ln -s ${buildPackages.yacc}/bin/yacc $toolchain/bin/yacc
ln -s ${buildPackages.yacc}/bin/bison $toolchain/bin/bison
ln -s ${buildPackages.flex}/bin/flex $toolchain/bin/flex
ln -s ${buildPackages.flex}/bin/flex++ $toolchain/bin/flex++
ln -s $toolchain/bin/flex $toolchain/bin/lex
ln -s ${buildPackages.m4}/bin/m4 $toolchain/usr/bin/m4
ln -s $toolchain/usr/bin/m4 $toolchain/usr/bin/gm4
ln -s ${buildPackages.m4}/bin/m4 $toolchain/bin/m4
ln -s $toolchain/bin/m4 $toolchain/bin/gm4
ln -s ${buildPackages.unifdef}/bin/unifdef $toolchain/usr/bin/unifdef
ln -s ${buildPackages.unifdef}/bin/unifdefall $toolchain/usr/bin/unifdefall
ln -s ${buildPackages.unifdef}/bin/unifdef $toolchain/bin/unifdef
ln -s ${buildPackages.unifdef}/bin/unifdefall $toolchain/bin/unifdefall
ln -s ${buildPackages.gperf}/bin/gperf $toolchain/usr/bin/gperf
ln -s ${buildPackages.indent}/bin/indent $toolchain/usr/bin/indent
ln -s ${buildPackages.ctags}/bin/ctags $toolchain/usr/bin/ctags
ln -s ${buildPackages.gperf}/bin/gperf $toolchain/bin/gperf
ln -s ${buildPackages.indent}/bin/indent $toolchain/bin/indent
ln -s ${buildPackages.ctags}/bin/ctags $toolchain/bin/ctags
'' + optionalString stdenv.isDarwin ''
for bin in ${getBin buildPackages.darwin.cctools}/bin/*; do
if ! [ -e "$toolchain/usr/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/usr/bin
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/usr/bin
ln -s ${mkdep-darwin-src} $toolchain/usr/bin/mkdep
ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/bin
ln -s ${mkdep-darwin-src} $toolchain/bin/mkdep
'')

View File

@ -1,4 +1,4 @@
{ lib, buildPackages, makeWrapper, writeText, runCommand
{ stdenv, lib, buildPackages, makeWrapper, writeText, runCommand
, CoreServices, ImageIO, CoreGraphics
, targetPlatform
, xcodePlatform ? targetPlatform.xcodePlatform or "MacOSX"
@ -36,14 +36,14 @@ let
'';
xcode-select = writeText "xcode-select" ''
#!/usr/bin/env sh
#!${stdenv.shell}
while [ $# -gt 0 ]; do
case "$1" in
-h | --help) ;; # noop
-s | --switch) shift;; # noop
-r | --reset) ;; # noop
-v | --version) echo xcode-select version ${xcodeSelectVersion} ;;
-p | --print-path) echo @DEVELOPER_DIR@ ;;
-p | -print-path | --print-path) echo @DEVELOPER_DIR@ ;;
--install) ;; # noop
esac
shift
@ -51,7 +51,7 @@ done
'';
xcrun = writeText "xcrun" ''
#!/usr/bin/env sh
#!${stdenv.shell}
while [ $# -gt 0 ]; do
case "$1" in
--sdk | -sdk) shift ;;
@ -86,16 +86,20 @@ runCommand "xcodebuild-${xcbuild.version}" {
inherit (xcbuild) meta;
# ensure that the toolchain goes in PATH
propagatedBuildInputs = [ "${toolchains}/XcodeDefault.xctoolchain/usr" ];
propagatedBuildInputs = [ "${toolchains}/XcodeDefault.xctoolchain" ];
passthru = { inherit xcbuild; };
passthru = {
inherit xcbuild;
toolchain = "${toolchains}/XcodeDefault.xctoolchain";
sdk = "${sdks}/${sdkName}";
platform = "${platforms}/${xcodePlatform}.platform";
};
preferLocalBuild = true;
} ''
mkdir -p $out/bin
mkdir -p $out/usr
ln -s $out/bin $out/usr/bin
ln -s $out $out/usr
mkdir -p $out/Library/Xcode
ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
@ -108,7 +112,8 @@ runCommand "xcodebuild-${xcbuild.version}" {
--add-flags "DERIVED_DATA_DIR=." \
--set DEVELOPER_DIR "$out" \
--set SDKROOT ${sdkName} \
--run '[ "$1" = "-version" ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0'
--run '[ "$1" = "-version" ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0' \
--run '[ "$1" = "-license" ] && exit 0'
substitute ${xcode-select} $out/bin/xcode-select \
--subst-var-by DEVELOPER_DIR $out

View File

@ -16306,6 +16306,10 @@ with pkgs;
python = python2;
gnused = gnused_422;
icu = icu59;
inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling
Kerberos AVFoundation MediaToolbox
CoreLocation Foundation AddressBook;
inherit (darwin) libobjc;
};
});

View File

@ -41,7 +41,6 @@ let
constituents =
[ jobs.tarball
jobs.cabal2nix.x86_64-darwin
jobs.emacs.x86_64-darwin
jobs.ghc.x86_64-darwin
jobs.git.x86_64-darwin
jobs.go.x86_64-darwin
@ -57,9 +56,20 @@ let
jobs.python3.x86_64-darwin
jobs.ruby.x86_64-darwin
jobs.rustc.x86_64-darwin
jobs.stack.x86_64-darwin
jobs.stdenv.x86_64-darwin
jobs.vim.x86_64-darwin
# UI apps
jobs.firefox.x86_64-darwin
jobs.qt5.qtmultimedia.x86_64-darwin
jobs.inkscape.x86_64-darwin
# jobs.gimp.x86_64-darwin
jobs.emacs.x86_64-darwin
# jobs.wireshark.x86_64-darwin
jobs.transmision-gtk.x86_64-darwin
# Tests
jobs.tests.cc-wrapper.x86_64-darwin
jobs.tests.cc-wrapper-clang.x86_64-darwin
jobs.tests.cc-wrapper-libcxx.x86_64-darwin