firefox: build on darwin
Fixes #30285 Some things done: - Add macOS frameworks needed - Fix RUST_BINDGEN handling. We need to pass all of NIX_CFLAGS_COMPILE to rust bindgen - Add custom install phase for darwin
This commit is contained in:
parent
4b71fe6d86
commit
8fba05403a
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
# macOS dependencies
|
# macOS dependencies
|
||||||
, xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox
|
, xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox
|
||||||
, CoreLocation, Foundation, libobjc
|
, CoreLocation, Foundation, AddressBook, libobjc, cups, rsync
|
||||||
|
|
||||||
## other
|
## other
|
||||||
|
|
||||||
@ -64,7 +64,6 @@
|
|||||||
# > the experience of Firefox users, you won't have any issues using the
|
# > the experience of Firefox users, you won't have any issues using the
|
||||||
# > official branding.
|
# > official branding.
|
||||||
, enableOfficialBranding ? true
|
, enableOfficialBranding ? true
|
||||||
, gcc
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert stdenv.cc.libc or null != null;
|
assert stdenv.cc.libc or null != null;
|
||||||
@ -74,6 +73,11 @@ let
|
|||||||
|
|
||||||
default-toolkit = if stdenv.isDarwin then "cairo-cocoa"
|
default-toolkit = if stdenv.isDarwin then "cairo-cocoa"
|
||||||
else "cairo-gtk${if gtk3Support then "3" else "2"}";
|
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
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (rec {
|
||||||
@ -100,7 +104,7 @@ stdenv.mkDerivation (rec {
|
|||||||
++ lib.optional gssSupport kerberos
|
++ lib.optional gssSupport kerberos
|
||||||
++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
|
++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
|
||||||
AVFoundation MediaToolbox CoreLocation
|
AVFoundation MediaToolbox CoreLocation
|
||||||
Foundation libobjc ];
|
Foundation libobjc AddressBook cups ];
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = [ "-I${nspr.dev}/include/nspr"
|
NIX_CFLAGS_COMPILE = [ "-I${nspr.dev}/include/nspr"
|
||||||
"-I${nss.dev}/include/nss"
|
"-I${nss.dev}/include/nss"
|
||||||
@ -116,7 +120,7 @@ stdenv.mkDerivation (rec {
|
|||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
[ autoconf213 which gnused pkgconfig perl python2 cargo rustc ]
|
[ autoconf213 which gnused pkgconfig perl python2 cargo rustc ]
|
||||||
++ lib.optional gtk3Support wrapGAppsHook
|
++ lib.optional gtk3Support wrapGAppsHook
|
||||||
++ lib.optional stdenv.isDarwin xcbuild
|
++ lib.optionals stdenv.isDarwin [ xcbuild rsync ]
|
||||||
++ extraNativeBuildInputs;
|
++ extraNativeBuildInputs;
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
@ -139,7 +143,15 @@ stdenv.mkDerivation (rec {
|
|||||||
# uses LLVM's libclang. To make sure all necessary flags are
|
# uses LLVM's libclang. To make sure all necessary flags are
|
||||||
# included we need to look in a few places.
|
# included we need to look in a few places.
|
||||||
# TODO: generalize this process for other use-cases.
|
# TODO: generalize this process for other use-cases.
|
||||||
echo "ac_add_options BINDGEN_CFLAGS='$(< ${stdenv.cc}/nix-support/libc-cflags) $(< ${stdenv.cc}/nix-support/cc-cflags) ${stdenv.cc.default_cxx_stdlib_compile} -idirafter ${llvmPackages.clang.cc}/lib/clang/${lib.getVersion llvmPackages.clang}/include $NIX_CFLAGS_COMPILE'" >> $MOZCONFIG
|
|
||||||
|
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 ''
|
'' + lib.optionalString googleAPISupport ''
|
||||||
# Google API key used by Chromium and Firefox.
|
# Google API key used by Chromium and Firefox.
|
||||||
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
|
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
|
||||||
@ -249,7 +261,12 @@ stdenv.mkDerivation (rec {
|
|||||||
paxmark m dist/bin/xpcshell
|
paxmark m dist/bin/xpcshell
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postInstall = ''
|
installPhase = if stdenv.isDarwin then ''
|
||||||
|
mkdir -p $out/Applications
|
||||||
|
cp -RL Firefox.app $out/Applications
|
||||||
|
'' else null;
|
||||||
|
|
||||||
|
postInstall = lib.optionalString stdenv.isLinux ''
|
||||||
# For grsecurity kernels
|
# For grsecurity kernels
|
||||||
paxmark m $out/lib/firefox*/{firefox,firefox-bin,plugin-container}
|
paxmark m $out/lib/firefox*/{firefox,firefox-bin,plugin-container}
|
||||||
|
|
||||||
@ -260,7 +277,7 @@ stdenv.mkDerivation (rec {
|
|||||||
gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
|
gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = lib.optionalString stdenv.isLinux ''
|
||||||
# Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
|
# Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
|
||||||
patchelf --set-rpath "${lib.getLib libnotify
|
patchelf --set-rpath "${lib.getLib libnotify
|
||||||
}/lib:$(patchelf --print-rpath "$out"/lib/firefox*/libxul.so)" \
|
}/lib:$(patchelf --print-rpath "$out"/lib/firefox*/libxul.so)" \
|
||||||
@ -270,11 +287,10 @@ stdenv.mkDerivation (rec {
|
|||||||
doInstallCheck = true;
|
doInstallCheck = true;
|
||||||
installCheckPhase = ''
|
installCheckPhase = ''
|
||||||
# Some basic testing
|
# Some basic testing
|
||||||
"$out/bin/firefox" --version
|
"$out${execdir}/${browserName}" --version
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
browserName = "firefox";
|
|
||||||
inherit version updateScript;
|
inherit version updateScript;
|
||||||
isFirefox3Like = true;
|
isFirefox3Like = true;
|
||||||
inherit isTorBrowserLike;
|
inherit isTorBrowserLike;
|
||||||
@ -282,6 +298,8 @@ stdenv.mkDerivation (rec {
|
|||||||
inherit nspr;
|
inherit nspr;
|
||||||
inherit ffmpegSupport;
|
inherit ffmpegSupport;
|
||||||
inherit gssSupport;
|
inherit gssSupport;
|
||||||
|
inherit execdir;
|
||||||
|
inherit browserName;
|
||||||
} // lib.optionalAttrs gtk3Support { inherit gtk3; };
|
} // lib.optionalAttrs gtk3Support { inherit gtk3; };
|
||||||
|
|
||||||
} // overrides)
|
} // overrides)
|
||||||
|
@ -98,24 +98,24 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [makeWrapper]
|
nativeBuildInputs = [ makeWrapper lndir ];
|
||||||
++ lib.optional (browser ? gtk3) browser.gtk3;
|
buildInputs = lib.optional (browser ? gtk3) browser.gtk3;
|
||||||
|
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
if [ ! -x "${browser}/bin/${browserName}" ]
|
if [ ! -x "${browser}${browser.execdir}/${browserName}" ]
|
||||||
then
|
then
|
||||||
echo "cannot find executable file \`${browser}/bin/${browserName}'"
|
echo "cannot find executable file \`${browser}${browser.execdir}/${browserName}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
makeWrapper "$(readlink -v --canonicalize-existing "${browser}/bin/${browserName}")" \
|
makeWrapper "$(readlink -v --canonicalize-existing "${browser}${browser.execdir}/${browserName}")" \
|
||||||
"$out/bin/${browserName}${nameSuffix}" \
|
"$out${browser.execdir}/${browserName}${nameSuffix}" \
|
||||||
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
|
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
|
||||||
--suffix LD_LIBRARY_PATH ':' "$libs" \
|
--suffix LD_LIBRARY_PATH ':' "$libs" \
|
||||||
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
--suffix-each GTK_PATH ':' "$gtk_modules" \
|
||||||
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
|
--suffix-each LD_PRELOAD ':' "$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))" \
|
||||||
--prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $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_APP_LAUNCHER "${browserName}${nameSuffix}" \
|
||||||
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
|
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \
|
||||||
${lib.optionalString (browser ? gtk3)
|
${lib.optionalString (browser ? gtk3)
|
||||||
@ -141,7 +141,7 @@ let
|
|||||||
|
|
||||||
mkdir -p $out/lib/mozilla
|
mkdir -p $out/lib/mozilla
|
||||||
for ext in ${toString nativeMessagingHosts}; do
|
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
|
done
|
||||||
|
|
||||||
# For manpages, in case the program supplies them
|
# For manpages, in case the program supplies them
|
||||||
|
@ -16308,7 +16308,7 @@ with pkgs;
|
|||||||
icu = icu59;
|
icu = icu59;
|
||||||
inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling
|
inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling
|
||||||
Kerberos AVFoundation MediaToolbox
|
Kerberos AVFoundation MediaToolbox
|
||||||
CoreLocation Foundation;
|
CoreLocation Foundation AddressBook;
|
||||||
inherit (darwin) libobjc;
|
inherit (darwin) libobjc;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user