about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-07-29 00:15:14 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2018-08-11 22:54:48 -0500
commit8fba05403ae6c34790179dc10fe048e67a40e243 (patch)
tree5c22271b34f9f9fec9133f68139ae7716aaa6767
parent4b71fe6d863e6b774b56c3a06d8ec2bcb8763df3 (diff)
downloadnixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar.gz
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar.bz2
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar.lz
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar.xz
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.tar.zst
nixlib-8fba05403ae6c34790179dc10fe048e67a40e243.zip
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
-rw-r--r--pkgs/applications/networking/browsers/firefox/common.nix36
-rw-r--r--pkgs/applications/networking/browsers/firefox/wrapper.nix16
-rw-r--r--pkgs/top-level/all-packages.nix2
3 files changed, 36 insertions, 18 deletions
diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix
index 0724bc3a6809..15486fc82e97 100644
--- a/pkgs/applications/networking/browsers/firefox/common.nix
+++ b/pkgs/applications/networking/browsers/firefox/common.nix
@@ -41,7 +41,7 @@
 
 # macOS dependencies
 , xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox
-, CoreLocation, Foundation, libobjc
+, CoreLocation, Foundation, AddressBook, libobjc, cups, rsync
 
 ## other
 
@@ -64,7 +64,6 @@
 # > the experience of Firefox users, you won't have any issues using the
 # > official branding.
 , enableOfficialBranding ? true
-, gcc
 }:
 
 assert stdenv.cc.libc or null != null;
@@ -74,6 +73,11 @@ let
 
   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 {
@@ -100,7 +104,7 @@ stdenv.mkDerivation (rec {
   ++ lib.optional  gssSupport kerberos
   ++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
                                      AVFoundation MediaToolbox CoreLocation
-                                     Foundation libobjc ];
+                                     Foundation libobjc AddressBook cups ];
 
   NIX_CFLAGS_COMPILE = [ "-I${nspr.dev}/include/nspr"
                          "-I${nss.dev}/include/nss"
@@ -116,7 +120,7 @@ stdenv.mkDerivation (rec {
   nativeBuildInputs =
     [ autoconf213 which gnused pkgconfig perl python2 cargo rustc ]
     ++ lib.optional gtk3Support wrapGAppsHook
-    ++ lib.optional stdenv.isDarwin xcbuild
+    ++ lib.optionals stdenv.isDarwin [ xcbuild rsync ]
     ++ extraNativeBuildInputs;
 
   preConfigure = ''
@@ -139,7 +143,15 @@ stdenv.mkDerivation (rec {
     # 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.
-    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 ''
     # Google API key used by Chromium and Firefox.
     # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
@@ -249,7 +261,12 @@ stdenv.mkDerivation (rec {
     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
     paxmark m $out/lib/firefox*/{firefox,firefox-bin,plugin-container}
 
@@ -260,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)" \
@@ -270,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;
@@ -282,6 +298,8 @@ stdenv.mkDerivation (rec {
     inherit nspr;
     inherit ffmpegSupport;
     inherit gssSupport;
+    inherit execdir;
+    inherit browserName;
   } // lib.optionalAttrs gtk3Support { inherit gtk3; };
 
 } // overrides)
diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix
index d2e7c59faff8..313d1b1d8c82 100644
--- a/pkgs/applications/networking/browsers/firefox/wrapper.nix
+++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix
@@ -98,24 +98,24 @@ 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}" ]
+        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 +141,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
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 8a04aeca3cd4..656f9d15fd03 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -16308,7 +16308,7 @@ with pkgs;
       icu = icu59;
       inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling
                                             Kerberos AVFoundation MediaToolbox
-                                            CoreLocation Foundation;
+                                            CoreLocation Foundation AddressBook;
       inherit (darwin) libobjc;
     };
   });