about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorMatthew Justin Bauer <mjbauer95@gmail.com>2018-04-25 00:30:32 -0500
committerGitHub <noreply@github.com>2018-04-25 00:30:32 -0500
commitd71d7c913ec3bb35135d1ddfbe74e561ba08e5c0 (patch)
treebb6d982959d709f3d23a11d7fe48c56c9c28c4fa /pkgs/development
parente4e85628066b0fa33ff5d3ba01ad24a50974639a (diff)
parent0a8c91a931ea270e8b1d66f592f6acba9b4b5fcf (diff)
downloadnixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar.gz
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar.bz2
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar.lz
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar.xz
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.tar.zst
nixlib-d71d7c913ec3bb35135d1ddfbe74e561ba08e5c0.zip
Merge pull request #39465 from matthewbauer/work
Various work on broken packages
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/libraries/glibmm/default.nix16
-rw-r--r--pkgs/development/libraries/gstreamer/bad/default.nix1
-rw-r--r--pkgs/development/libraries/gstreamer/good/default.nix5
-rw-r--r--pkgs/development/libraries/gstreamer/ugly/default.nix9
-rw-r--r--pkgs/development/libraries/libdvdnav/default.nix2
-rw-r--r--pkgs/development/libraries/libmtp/default.nix5
-rw-r--r--pkgs/development/libraries/live555/default.nix28
-rw-r--r--pkgs/development/libraries/qt-5/mkDerivation.nix5
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebengine.nix95
-rw-r--r--pkgs/development/libraries/schroedinger/default.nix16
-rw-r--r--pkgs/development/tools/build-managers/gn/default.nix153
11 files changed, 239 insertions, 96 deletions
diff --git a/pkgs/development/libraries/glibmm/default.nix b/pkgs/development/libraries/glibmm/default.nix
index a3af96d51edc..3c3b49e66161 100644
--- a/pkgs/development/libraries/glibmm/default.nix
+++ b/pkgs/development/libraries/glibmm/default.nix
@@ -1,19 +1,27 @@
-{ stdenv, fetchurl, pkgconfig, gnum4, glib, libsigcxx }:
+{ stdenv, fetchurl, fetchpatch, pkgconfig, gnum4, glib, libsigcxx }:
 
 let
-  ver_maj = "2.54";
-  ver_min = "1";
+  ver_maj = "2.56";
+  ver_min = "0";
 in
 stdenv.mkDerivation rec {
   name = "glibmm-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/glibmm/${ver_maj}/${name}.tar.xz";
-    sha256 = "0jkapw18icz59cmlmsl00nwwz0wh291kb4hc9z9hxmq45drqrhkw";
+    sha256 = "1abrkqhca5p8n6ly3vp1232rny03s7lrd8f8iz2m2m141nxgqx3f";
   };
 
   outputs = [ "out" "dev" ];
 
+  patchFlags = "-p0";
+  patches = [
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/macports/macports-ports/e864b2340be9ef003d8ff4aef92e7151d06287dd/devel/glibmm/files/0001-ustring-Fix-wchar-conversion-on-macOS-with-libc.patch";
+      sha256 = "02qvnailw1i59cjbj3cy7y02kfcivsvkdjrf4njkp4plarayyqp9";
+    })
+  ];
+
   nativeBuildInputs = [ pkgconfig gnum4 ];
   propagatedBuildInputs = [ glib libsigcxx ];
 
diff --git a/pkgs/development/libraries/gstreamer/bad/default.nix b/pkgs/development/libraries/gstreamer/bad/default.nix
index 73cbaa0f8070..8ebd70921135 100644
--- a/pkgs/development/libraries/gstreamer/bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/bad/default.nix
@@ -35,6 +35,7 @@ stdenv.mkDerivation rec {
     '';
     license     = licenses.lgpl2Plus;
     platforms   = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ matthewbauer ];
   };
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/gstreamer/good/default.nix b/pkgs/development/libraries/gstreamer/good/default.nix
index 5c10221b27d7..21376ce79c1c 100644
--- a/pkgs/development/libraries/gstreamer/good/default.nix
+++ b/pkgs/development/libraries/gstreamer/good/default.nix
@@ -6,6 +6,7 @@
 , libsoup, libpulseaudio, libintl
 , darwin, lame, mpg123, twolame
 , gtkSupport ? false, gtk3 ? null
+, ncurses
 }:
 
 assert gtkSupport -> gtk3 != null;
@@ -26,6 +27,7 @@ stdenv.mkDerivation rec {
     '';
     license     = licenses.lgpl2Plus;
     platforms   = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ matthewbauer ];
   };
 
   src = fetchurl {
@@ -39,11 +41,14 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig python meson ninja gettext ];
 
+  NIX_LDFLAGS = "-lncurses";
+
   buildInputs = [
     gst-plugins-base orc bzip2
     libdv libvpx speex flac taglib
     cairo gdk_pixbuf aalib libcaca
     libsoup libshout lame mpg123 twolame libintl
+    ncurses
   ]
   ++ optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
   ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ];
diff --git a/pkgs/development/libraries/gstreamer/ugly/default.nix b/pkgs/development/libraries/gstreamer/ugly/default.nix
index a5449abb9f7d..004bb0715f26 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -1,13 +1,14 @@
 { stdenv, fetchurl, meson, ninja, pkgconfig, python
 , gst-plugins-base, orc, gettext
 , a52dec, libcdio, libdvdread
-, libmad, libmpeg2, x264, libintl
+, libmad, libmpeg2, x264, libintl, lib
+, darwin
 }:
 
 stdenv.mkDerivation rec {
   name = "gst-plugins-ugly-1.14.0";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Gstreamer Ugly Plugins";
     homepage    = "https://gstreamer.freedesktop.org";
     longDescription = ''
@@ -18,6 +19,7 @@ stdenv.mkDerivation rec {
     '';
     license     = licenses.lgpl2Plus;
     platforms   = platforms.unix;
+    maintainers = with maintainers; [ matthewbauer ];
   };
 
   src = fetchurl {
@@ -34,5 +36,6 @@ stdenv.mkDerivation rec {
     a52dec libcdio libdvdread
     libmad libmpeg2 x264
     libintl
-  ];
+  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks;
+    [ IOKit CoreFoundation DiskArbitration ]);
 }
diff --git a/pkgs/development/libraries/libdvdnav/default.nix b/pkgs/development/libraries/libdvdnav/default.nix
index 42321b2f866a..b0dfd1e8fc12 100644
--- a/pkgs/development/libraries/libdvdnav/default.nix
+++ b/pkgs/development/libraries/libdvdnav/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     description = "A library that implements DVD navigation features such as DVD menus";
     license = stdenv.lib.licenses.gpl2;
     maintainers = [ stdenv.lib.maintainers.wmertens ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 
   passthru = { inherit libdvdread; };
diff --git a/pkgs/development/libraries/libmtp/default.nix b/pkgs/development/libraries/libmtp/default.nix
index 88ef55715a7c..c3061626a6ae 100644
--- a/pkgs/development/libraries/libmtp/default.nix
+++ b/pkgs/development/libraries/libmtp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libusb1 }:
+{ stdenv, fetchurl, pkgconfig, libusb1, libiconv }:
 
 stdenv.mkDerivation rec {
   name = "libmtp-1.1.15";
@@ -10,6 +10,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "bin" "dev" "out" ];
 
+  buildInputs = [ libiconv ];
   propagatedBuildInputs = [ libusb1 ];
   nativeBuildInputs = [ pkgconfig ];
 
@@ -24,7 +25,7 @@ stdenv.mkDerivation rec {
       in the form of a library suitable primarily for POSIX compliant operating
       systems. We implement MTP Basic, the stuff proposed for standardization.
       '';
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
     maintainers = [ ];
   };
 }
diff --git a/pkgs/development/libraries/live555/default.nix b/pkgs/development/libraries/live555/default.nix
index 1479f7b6153b..e0cf3328bac2 100644
--- a/pkgs/development/libraries/live555/default.nix
+++ b/pkgs/development/libraries/live555/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, lib, darwin }:
 
 # Based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD
 let
@@ -12,19 +12,23 @@ stdenv.mkDerivation {
     sha256 = "0zi47asv1qmb09g321m02q684i3c90vci0mgkdh1mlmx2rbg1d1d";
   };
 
-  postPatch = "sed 's,/bin/rm,rm,g' -i genMakefiles"
-  + stdenv.lib.optionalString (stdenv ? glibc) ''
-
+  postPatch = ''
+    sed 's,/bin/rm,rm,g' -i genMakefiles
+    sed \
+      -e 's/$(INCLUDES) -I. -O2 -DSOCKLEN_T/$(INCLUDES) -I. -O2 -I. -fPIC -DRTSPCLIENT_SYNCHRONOUS_INTERFACE=1 -DSOCKLEN_T/g' \
+      -i config.linux
+  '' + stdenv.lib.optionalString (stdenv ? glibc) ''
     substituteInPlace liveMedia/include/Locale.hh \
       --replace '<xlocale.h>' '<locale.h>'
   '';
 
   configurePhase = ''
-    sed \
-      -e 's/$(INCLUDES) -I. -O2 -DSOCKLEN_T/$(INCLUDES) -I. -O2 -I. -fPIC -DRTSPCLIENT_SYNCHRONOUS_INTERFACE=1 -DSOCKLEN_T/g' \
-      -i config.linux
-
-    ./genMakefiles linux
+    ./genMakefiles ${{
+      x86_64-darwin = "macosx";
+      i686-linux = "linux";
+      x86_64-linux = "linux-64bit";
+      aarch64-linux = "linux-64bit";
+    }.${stdenv.system}}
   '';
 
   installPhase = ''
@@ -35,10 +39,12 @@ stdenv.mkDerivation {
     done
   '';
 
-  meta = with stdenv.lib; {
+  nativeBuildInputs = lib.optional stdenv.isDarwin darwin.cctools;
+
+  meta = with lib; {
     description = "Set of C++ libraries for multimedia streaming, using open standard protocols (RTP/RTCP, RTSP, SIP)";
     homepage = http://www.live555.com/liveMedia/;
     license = licenses.lgpl21Plus;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/qt-5/mkDerivation.nix b/pkgs/development/libraries/qt-5/mkDerivation.nix
index 739c9b4a1608..96014cfbc779 100644
--- a/pkgs/development/libraries/qt-5/mkDerivation.nix
+++ b/pkgs/development/libraries/qt-5/mkDerivation.nix
@@ -9,9 +9,8 @@ args:
 let
   args_ = {
 
-    qmakeFlags =
-      (args.qmakeFlags or [])
-      ++ [ ("CONFIG+=" + (if debug then "debug" else "release")) ];
+    qmakeFlags = [ ("CONFIG+=" + (if debug then "debug" else "release")) ]
+              ++ (args.qmakeFlags or []);
 
     NIX_CFLAGS_COMPILE =
       optional (!debug) "-DQT_NO_DEBUG"
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
index 08345510d787..e798d529ce1b 100644
--- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
@@ -11,9 +11,8 @@
 , libcap
 , pciutils
 , systemd
-
 , enableProprietaryCodecs ? true
-
+, gn, darwin, openbsm
 , lib, stdenv # lib.optional, needsPax
 }:
 
@@ -25,7 +24,7 @@ qtModule {
   name = "qtwebengine";
   qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ];
   nativeBuildInputs = [
-    bison coreutils flex git gperf ninja pkgconfig python2 which
+    bison coreutils flex git gperf ninja pkgconfig python2 which gn
   ];
   doCheck = true;
   outputs = [ "bin" "dev" "out" ];
@@ -61,8 +60,50 @@ qtModule {
 
       sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
         src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
+    ''
+    + optionalString stdenv.isDarwin ''
+      # Remove annoying xcode check
+      substituteInPlace mkspecs/features/platform.prf \
+        --replace "lessThan(QMAKE_XCODE_VERSION, 7.3)" false
+      substituteInPlace src/core/config/mac_osx.pri \
+        --replace /usr ${stdenv.cc} \
+        --replace "isEmpty(QMAKE_MAC_SDK_VERSION)" false
+
+    # FIXME Needed with old Apple SDKs
+    # Abandon all hope ye who try to make sense of this.
+    substituteInPlace src/3rdparty/chromium/base/mac/foundation_util.mm \
+      --replace "NSArray<NSString*>*" "NSArray*"
+    substituteInPlace src/3rdparty/chromium/base/mac/sdk_forward_declarations.h \
+      --replace "NSDictionary<VNImageOption, id>*" "NSDictionary*" \
+      --replace "NSArray<VNRequest*>*" "NSArray*" \
+      --replace "typedef NSString* VNImageOption NS_STRING_ENUM" "typedef NSString* VNImageOption"
+
+    cat <<EOF > src/3rdparty/chromium/build/mac/find_sdk.py
+#!/usr/bin/env python
+print("10.10.0")
+print("")
+EOF
+
+    cat <<EOF > src/3rdparty/chromium/build/config/mac/sdk_info.py
+#!/usr/bin/env python
+print('xcode_version="9.1"')
+print('xcode_version_int=9')
+print('xcode_build="9B55"')
+print('machine_os_build="17E199"')
+print('sdk_path=""')
+print('sdk_version="10.10"')
+print('sdk_platform_path=""')
+print('sdk_build="17B41"')
+EOF
+
+    # Apple has some secret stuff they don't share with OpenBSM
+    substituteInPlace src/3rdparty/chromium/base/mac/mach_port_broker.mm \
+      --replace "audit_token_to_pid(msg.trailer.msgh_audit)" "msg.trailer.msgh_audit.val[5]"
+    substituteInPlace src/3rdparty/chromium/sandbox/mac/bootstrap_sandbox.cc \
+      --replace "audit_token_to_pid(msg.trailer.msgh_audit)" "msg.trailer.msgh_audit.val[5]"
     '';
 
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10 -DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10";
 
   preConfigure = ''
     export NINJAFLAGS=-j$NIX_BUILD_CORES
@@ -70,13 +111,9 @@ qtModule {
     if [ -d "$PWD/tools/qmake" ]; then
         QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
     fi
- '';
+   '';
 
-  qmakeFlags =
-    [
-      # Use system Ninja because bootstrapping it is fragile
-      "WEBENGINE_CONFIG+=use_system_ninja"
-    ] ++ optional enableProprietaryCodecs "WEBENGINE_CONFIG+=use_proprietary_codecs";
+  qmakeFlags = optional enableProprietaryCodecs "-- -proprietary-codecs";
 
   propagatedBuildInputs = [
     # Image formats
@@ -90,9 +127,10 @@ qtModule {
 
     # Text rendering
     harfbuzz icu
-  ]
-  ++ optionals (!stdenv.isDarwin) [
-    dbus zlib minizip snappy nss protobuf jsoncpp libevent
+
+    libevent
+  ] ++ optionals (!stdenv.isDarwin) [
+    dbus zlib minizip snappy nss protobuf jsoncpp
 
     # Audio formats
     alsaLib
@@ -106,17 +144,44 @@ qtModule {
     # X11 libs
     xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
     xorg.libXcomposite xorg.libXdamage libdrm
-  ];
+  ]
+
+  # FIXME These dependencies shouldn't be needed but can't find a way
+  # around it. Chromium pulls this in while bootstrapping GN.
+  ++ lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
+    libobjc
+    cctools
+
+    # frameworks
+    ApplicationServices
+    Foundation
+    AppKit
+    ImageCaptureCore
+    CoreBluetooth
+    IOBluetooth
+    CoreWLAN
+    Quartz
+    Cocoa
+
+    openbsm
+    libunwind
+  ]);
 
   dontUseNinjaBuild = true;
   dontUseNinjaInstall = true;
 
-  postInstall = ''
+  postInstall = lib.optionalString stdenv.isLinux ''
     cat > $out/libexec/qt.conf <<EOF
     [Paths]
     Prefix = ..
     EOF
-
     paxmark m $out/libexec/QtWebEngineProcess
   '';
+
+  meta = with lib; {
+    description = "A web engine based on the Chromium web browser";
+    maintainers = with maintainers; [ matthewbauer ];
+    platforms = platforms.unix;
+  };
+
 }
diff --git a/pkgs/development/libraries/schroedinger/default.nix b/pkgs/development/libraries/schroedinger/default.nix
index 2309719c2bdc..167fe4190764 100644
--- a/pkgs/development/libraries/schroedinger/default.nix
+++ b/pkgs/development/libraries/schroedinger/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, orc, pkgconfig }:
+{ stdenv, fetchurl, orc, pkgconfig, fetchpatch, autoreconfHook }:
 
 stdenv.mkDerivation {
   name = "schroedinger-1.0.11";
@@ -13,15 +13,23 @@ stdenv.mkDerivation {
 
   outputs = [ "out" "dev" "devdoc" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
   buildInputs = [ orc ];
 
-  doCheck = true;
+  doCheck = (!stdenv.isDarwin);
+
+  patchFlags = "-p0";
+  patches = [
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/macports/macports-ports/master/multimedia/schroedinger/files/patch-testsuite-Makefile.am.diff";
+      sha256 = "0cc8ymvgjgwy7ghca2dd8m8pxpinf27s2i8krf2m3fzv2ckq09v3";
+    })
+  ];
 
   meta = with stdenv.lib; {
     homepage = http://diracvideo.org/;
     maintainers = [ maintainers.spwhitt ];
     license = [ licenses.mpl11 licenses.lgpl2 licenses.mit ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/tools/build-managers/gn/default.nix b/pkgs/development/tools/build-managers/gn/default.nix
index 5e7dd5214a04..bfbb2b4e3308 100644
--- a/pkgs/development/tools/build-managers/gn/default.nix
+++ b/pkgs/development/tools/build-managers/gn/default.nix
@@ -1,77 +1,124 @@
-{ stdenv, lib, fetchgit, fetchurl, libevent, ninja, python }:
+{ stdenv, lib, fetchgit, fetchurl, fetchpatch
+, libevent, ninja, python, darwin }:
 
 let
   depsGit = {
     "tools/gn" = fetchgit {
       url = "https://chromium.googlesource.com/chromium/src/tools/gn";
-      rev = "d0c518db129975ce88ff1de26c857873b0619c4b";
-      sha256 = "0l15vzmjyx6bwlz1qhn3fy7yx3qzzxr3drnkj3l0p0fmyxza52vx";
+      rev = "0fa417a0d2d8484e9a5a636e3301da322f586601";
+      sha256 = "0pigcl14yc4aak6q1ghfjxdz2ah4fg4m2r5y3asw2rz6mpr5y9z0";
     };
     "base" = fetchgit {
       url = "https://chromium.googlesource.com/chromium/src/base";
-      rev = "bc6e3ce8ca01b894751e1f7b22b561e3ae2e7f17";
-      sha256 = "1yl49v6nxbrfms52xf7fiwh7d4301m2aj744pa3hzzh989c5j6g5";
+      rev = "ab1d7c3b92ce9c9bc756bdefb8338360d1a33a1e";
+      sha256 = "15wis6qg9ka62k6v1vamg0bp3v5vkpapg485jsn4bbfcaqp6di0f";
     };
     "build" = fetchgit {
       url = "https://chromium.googlesource.com/chromium/src/build";
-      rev = "e934a19ae908081fba13769924e4ea45a7a451ce";
-      sha256 = "0jhy418vaiin7djg9zvk83f8zhasigki4442x5j7gkmgmgmyc4am";
+      rev = "8d44c08a4c9997695db8098198bdd5026bc7a6f9";
+      sha256 = "19sajgf55xfmvnwvy2ss7g6pyljp751cfsws30w415m6m00lmpxl";
     };
     "config" = fetchgit {
       url = "https://chromium.googlesource.com/chromium/src/build/config";
-      rev = "df16c6a2c070704b0a25efe46ee9af16de1e65b3";
-      sha256 = "1x18syzz1scwhd8lf448hy5lnfpq118l403x9qmwm0np318w09wg";
+      rev = "14116c0cdcb9e28995ca8bb384a12e5c9dbd1dbb";
+      sha256 = "04nif0lm4wcy05b7xhal023874s4r0iq067q57cgwdm72i2gml40";
     };
     "testing/gtest" = fetchgit {
       url = "https://chromium.googlesource.com/chromium/testing/gtest";
       rev = "585ec31ea716f08233a815e680fc0d4699843938";
       sha256 = "0csn1cza66851nmxxiw42smsm3422mx67vcyykwn0a71lcjng6rc";
     };
+    "third_party/apple_apsl" = fetchurl {
+      url = "https://chromium.googlesource.com/chromium/src/third_party/+archive/8e6ccb8c74db6dfa15dd21401ace3ac96c054cf7/apple_apsl.tar.gz";
+      sha256 = "0sc7b7zdw7f9piyyijl7xq3v1fzflqlck1apwm8kvgdhkyz3l63k";
+    };
   };
 
-in
-  stdenv.mkDerivation rec {
-    name = "gn";
-    version = "0.0.0.20170629";
-    sourceRoot = ".";
+in stdenv.mkDerivation {
+  name = "gn";
+  version = "20180423";
+  sourceRoot = ".";
 
-    unpackPhase = ''
-      ${lib.concatStringsSep "\n" (
-        lib.mapAttrsToList (n: v: ''
-          mkdir -p $sourceRoot/${n}
+  unpackPhase = ''
+    ${lib.concatStringsSep "\n" (
+      lib.mapAttrsToList (n: v: ''
+        mkdir -p $sourceRoot/${n}
+        if [ -d ${v} ]; then
           cp -r ${v}/* $sourceRoot/${n}
-        '') depsGit)}
-    '';
-
-    postPatch = ''
-      # Patch shebands (for sandbox build)
-      chmod u+w -R build
-      patchShebangs build
-
-      # Patch out Chromium-bundled libevent
-      chmod u+w tools/gn/bootstrap tools/gn/bootstrap/bootstrap.py
-      sed -i -e '/static_libraries.*libevent/,/^ *\]\?[})]$/d' \
-          tools/gn/bootstrap/bootstrap.py
-    '';
-
-    NIX_LDFLAGS = "-levent";
-
-    nativeBuildInputs = [ ninja python ];
-    buildInputs = [ libevent ];
-
-    buildPhase = ''
-      python tools/gn/bootstrap/bootstrap.py -s
-    '';
-
-    installPhase = ''
-      install -vD out/Release/gn "$out/bin/gn"
-    '';
-
-    meta = with stdenv.lib; {
-      description = "A meta-build system that generates NinjaBuild files";
-      homepage = https://chromium.googlesource.com/chromium/src/tools/gn;
-      license = licenses.bsd3;
-      platforms = platforms.linux;
-      maintainers = [ maintainers.stesie ];
-    };
-  }
+        else
+          mkdir -p $sourceRoot/${n}
+          pushd $sourceRoot/${n}
+          unpackFile ${v}
+          popd
+        fi
+      '') depsGit)}
+
+    chmod u+w -R $sourceRoot
+  '';
+
+  patches = [
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/Eloston/ungoogled-chromium/master/resources/patches/ungoogled-chromium/macos/fix-gn-bootstrap.patch";
+      sha256 = "1h8jgxznm7zrxlzb4wcfx4zx4lyvfrmpd0r7cd7h0s23wn8ibb3a";
+    })
+  ];
+
+  postPatch = ''
+    # Disable libevent bootstrapping (we will provide it).
+    sed -i -e '/static_libraries.*libevent/,/^ *\]\?[})]$/d' \
+      tools/gn/bootstrap/bootstrap.py
+
+    # FIXME Needed with old Apple SDKs
+    substituteInPlace base/mac/foundation_util.mm \
+      --replace "NSArray<NSString*>*" "NSArray*"
+    substituteInPlace base/mac/sdk_forward_declarations.h \
+      --replace "NSDictionary<VNImageOption, id>*" "NSDictionary*" \
+      --replace "NSArray<VNRequest*>*" "NSArray*" \
+      --replace "typedef NSString* VNImageOption NS_STRING_ENUM" "typedef NSString* VNImageOption"
+
+    # Patch shebangs (for sandbox build)
+    patchShebangs build
+  '';
+
+  # FIXME again this shouldn't be necessary but I can't figure out a better way
+  NIX_CFLAGS_COMPILE = "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10 -DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10";
+
+  NIX_LDFLAGS = "-levent";
+
+  nativeBuildInputs = [ ninja python ];
+  buildInputs = [ libevent ]
+
+  # FIXME These dependencies shouldn't be needed but can't find a way
+  # around it. Chromium pulls this in while bootstrapping GN.
+  ++ lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
+    libobjc
+    cctools
+
+    # frameworks
+    ApplicationServices
+    Foundation
+    AppKit
+    ImageCaptureCore
+    CoreBluetooth
+    IOBluetooth
+    CoreWLAN
+    Quartz
+    Cocoa
+  ]);
+
+  buildPhase = ''
+    python tools/gn/bootstrap/bootstrap.py -s
+  '';
+
+  installPhase = ''
+    install -vD out/Release/gn "$out/bin/gn"
+  '';
+
+  meta = with lib; {
+    description = "A meta-build system that generates NinjaBuild files";
+    homepage = https://chromium.googlesource.com/chromium/src/tools/gn;
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ stesie matthewbauer ];
+  };
+}