From 0edb441a0ee44bea1bf448653d2b11679fdcd287 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 10 Jul 2018 18:10:04 -0400 Subject: [PATCH 1/7] firefox: build on darwin Fixes #30285 --- .../networking/browsers/firefox/common.nix | 20 ++++++++++++++----- .../networking/browsers/firefox/packages.nix | 2 +- pkgs/development/tools/xcbuild/wrapper.nix | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 336cd255661..ec9ca9bf2a4 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -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,9 @@ , safeBrowsingSupport ? false , drmSupport ? false +# macOS dependencies +, xcbuild, CoreMedia + ## other # As stated by Sylvestre Ledru (@sylvestre) on Nov 22, 2017 at @@ -60,13 +63,16 @@ # > 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; 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"}"; in stdenv.mkDerivation (rec { @@ -90,13 +96,16 @@ 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 ]; NIX_CFLAGS_COMPILE = "-I${nspr.dev}/include/nspr -I${nss.dev}/include/nss -I${glib.dev}/include/gio-unix-2.0"; nativeBuildInputs = [ autoconf213 which gnused pkgconfig perl python2 cargo rustc ] - ++ lib.optional gtk3Support wrapGAppsHook ++ extraNativeBuildInputs; + ++ lib.optional gtk3Support wrapGAppsHook + ++ lib.optional stdenv.isDarwin xcbuild + ++ extraNativeBuildInputs; preConfigure = '' # remove distributed configuration files @@ -146,7 +155,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) [ diff --git a/pkgs/applications/networking/browsers/firefox/packages.nix b/pkgs/applications/networking/browsers/firefox/packages.nix index f1d7b216120..1e257dd2c48 100644 --- a/pkgs/applications/networking/browsers/firefox/packages.nix +++ b/pkgs/applications/networking/browsers/firefox/packages.nix @@ -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"; diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix index 77ef8565a34..64bf78d0cfb 100644 --- a/pkgs/development/tools/xcbuild/wrapper.nix +++ b/pkgs/development/tools/xcbuild/wrapper.nix @@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do -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 From b5d529d52f956a9830d2aa3b1042071216c30d86 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 11 Jul 2018 11:45:23 -0400 Subject: [PATCH 2/7] xcbuild: cleanup --- pkgs/development/tools/xcbuild/platforms.nix | 3 +- pkgs/development/tools/xcbuild/sdks.nix | 9 +-- pkgs/development/tools/xcbuild/toolchains.nix | 56 +++++++++---------- pkgs/development/tools/xcbuild/wrapper.nix | 22 +++++--- 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/pkgs/development/tools/xcbuild/platforms.nix b/pkgs/development/tools/xcbuild/platforms.nix index bc60af9e1a5..e20dc878b53 100644 --- a/pkgs/development/tools/xcbuild/platforms.nix +++ b/pkgs/development/tools/xcbuild/platforms.nix @@ -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 diff --git a/pkgs/development/tools/xcbuild/sdks.nix b/pkgs/development/tools/xcbuild/sdks.nix index b0af26e87c1..74192d9c674 100644 --- a/pkgs/development/tools/xcbuild/sdks.nix +++ b/pkgs/development/tools/xcbuild/sdks.nix @@ -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 '' diff --git a/pkgs/development/tools/xcbuild/toolchains.nix b/pkgs/development/tools/xcbuild/toolchains.nix index 01a8fbdb0b0..59e009a4338 100644 --- a/pkgs/development/tools/xcbuild/toolchains.nix +++ b/pkgs/development/tools/xcbuild/toolchains.nix @@ -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 '') diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix index 64bf78d0cfb..d2044ea40ad 100644 --- a/pkgs/development/tools/xcbuild/wrapper.nix +++ b/pkgs/development/tools/xcbuild/wrapper.nix @@ -1,4 +1,5 @@ -{ lib, buildPackages, makeWrapper, writeText, runCommand +{ stdenv, lib, buildPackages, makeWrapper, writeText, runCommand +, bash , CoreServices, ImageIO, CoreGraphics , targetPlatform , xcodePlatform ? targetPlatform.xcodePlatform or "MacOSX" @@ -36,7 +37,7 @@ let ''; xcode-select = writeText "xcode-select" '' -#!/usr/bin/env sh +#!${bash}/bin/sh while [ $# -gt 0 ]; do case "$1" in -h | --help) ;; # noop @@ -51,7 +52,7 @@ done ''; xcrun = writeText "xcrun" '' -#!/usr/bin/env sh +#!${bash}/bin/sh while [ $# -gt 0 ]; do case "$1" in --sdk | -sdk) shift ;; @@ -86,16 +87,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 +113,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 From 72a1bc9a28d2a8e2c6e26a551932c4a054a525be Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 11 Jul 2018 16:48:47 -0400 Subject: [PATCH 3/7] release18.09: add darwin target jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are some parts of the release that I want to get working before we release 18.09. There have been lots of improvements since 18.03 (as well as some regressions). To make sure the release is well-tested we need to add these apps in the jobset. Most of these are UI apps that are now available. List of new apps added to the release: - wireshark - firefox - qtmultimedia (already in unstable) - inkscape (already in unstable) - gimp - wireshark - transmission Also add ‘stack’. This is one of the Haskell packages hitting the ARG_MAX limit on macOS (getconf ARG_MAX == 262144). This has not been solved yet but it will need to be resolved by 18.09. Making it block here will prevent this regression in the future. [squashed] release: remove broken from darwin-tested removes: - gimp - qtmultimedia --- pkgs/top-level/release.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix index 5553c4d5265..2c1dabe0db2 100644 --- a/pkgs/top-level/release.nix +++ b/pkgs/top-level/release.nix @@ -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 From 4b71fe6d863e6b774b56c3a06d8ec2bcb8763df3 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 11 Jul 2018 17:01:35 -0400 Subject: [PATCH 4/7] firefox: cleanup expression - Add a few more macOS frameworks needed - Fix RUST_BINDGEN handling. We need to pass all of NIX_CFLAGS_COMPILE to rust bindgen --- .../networking/browsers/firefox/common.nix | 28 +++++++++++++++---- pkgs/top-level/all-packages.nix | 4 +++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index ec9ca9bf2a4..0724bc3a680 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -40,7 +40,8 @@ , drmSupport ? false # macOS dependencies -, xcbuild, CoreMedia +, xcbuild, CoreMedia, ExceptionHandling, Kerberos, AVFoundation, MediaToolbox +, CoreLocation, Foundation, libobjc ## other @@ -97,9 +98,20 @@ stdenv.mkDerivation (rec { ++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ] ++ lib.optional gtk3Support gtk3 ++ lib.optional gssSupport kerberos - ++ lib.optionals stdenv.isDarwin [ CoreMedia ]; + ++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos + AVFoundation MediaToolbox CoreLocation + Foundation libobjc ]; - 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 ] @@ -120,10 +132,14 @@ 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. + 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 '' + lib.optionalString googleAPISupport '' # Google API key used by Chromium and Firefox. # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ff462fd1233..8a04aeca3cd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; + inherit (darwin) libobjc; }; }); From 8fba05403ae6c34790179dc10fe048e67a40e243 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 29 Jul 2018 00:15:14 -0400 Subject: [PATCH 5/7] 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 --- .../networking/browsers/firefox/common.nix | 36 ++++++++++++++----- .../networking/browsers/firefox/wrapper.nix | 16 ++++----- pkgs/top-level/all-packages.nix | 2 +- 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 0724bc3a680..15486fc82e9 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 d2e7c59faff..313d1b1d8c8 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 8a04aeca3cd..656f9d15fd0 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; }; }); From c391bd3dd31cec6662995bfe6cea7a36fa3e0b5a Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 11 Jul 2018 11:45:23 -0400 Subject: [PATCH 6/7] xcbuild: cleanup fix shell shebang --- pkgs/development/tools/xcbuild/wrapper.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix index d2044ea40ad..1735124439e 100644 --- a/pkgs/development/tools/xcbuild/wrapper.nix +++ b/pkgs/development/tools/xcbuild/wrapper.nix @@ -1,5 +1,4 @@ { stdenv, lib, buildPackages, makeWrapper, writeText, runCommand -, bash , CoreServices, ImageIO, CoreGraphics , targetPlatform , xcodePlatform ? targetPlatform.xcodePlatform or "MacOSX" @@ -37,7 +36,7 @@ let ''; xcode-select = writeText "xcode-select" '' -#!${bash}/bin/sh +#!${stdenv.shell} while [ $# -gt 0 ]; do case "$1" in -h | --help) ;; # noop @@ -52,7 +51,7 @@ done ''; xcrun = writeText "xcrun" '' -#!${bash}/bin/sh +#!${stdenv.shell} while [ $# -gt 0 ]; do case "$1" in --sdk | -sdk) shift ;; From 08655b16f29e559bf6a4b10a6577e61febbf641f Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 8 Aug 2018 21:14:59 -0400 Subject: [PATCH 7/7] firefox: fix darwin wrapper - add execdir passthru usually this is /bin on macOS it is different. --- .../networking/browsers/firefox-bin/default.nix | 1 + pkgs/applications/networking/browsers/firefox/common.nix | 2 +- pkgs/applications/networking/browsers/firefox/wrapper.nix | 6 +++++- .../networking/browsers/tor-browser-bundle/default.nix | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix index 570180d4c4d..1fbcb3d9714 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/default.nix +++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix @@ -174,6 +174,7 @@ stdenv.mkDerivation { gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped") ''; + passthru.execdir = "/bin"; passthru.ffmpegSupport = true; passthru.gssSupport = true; # update with: diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 15486fc82e9..e2a3d4430df 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -263,7 +263,7 @@ stdenv.mkDerivation (rec { installPhase = if stdenv.isDarwin then '' mkdir -p $out/Applications - cp -RL Firefox.app $out/Applications + cp -LR dist/Firefox.app $out/Applications '' else null; postInstall = lib.optionalString stdenv.isLinux '' diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 313d1b1d8c8..a60d533c5a5 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -101,7 +101,11 @@ let nativeBuildInputs = [ makeWrapper lndir ]; buildInputs = lib.optional (browser ? gtk3) browser.gtk3; - buildCommand = '' + 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}${browser.execdir}/${browserName}'" diff --git a/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix b/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix index 031c520275f..50b992253ce 100644 --- a/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix +++ b/pkgs/applications/networking/browsers/tor-browser-bundle/default.nix @@ -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/;