@@ -1,77 +1,124 @@
1−{ stdenv, lib, fetchgit, fetchurl, libevent, ninja, python }:
1+{ stdenv, lib, fetchgit, fetchurl, fetchpatch
2+, libevent, ninja, python, darwin }:
23
34let
45 depsGit = {
56 "tools/gn" = fetchgit {
67 url = "https://chromium.googlesource.com/chromium/src/tools/gn";
7− rev = "d0c518db129975ce88ff1de26c857873b0619c4b";
8− sha256 = "0l15vzmjyx6bwlz1qhn3fy7yx3qzzxr3drnkj3l0p0fmyxza52vx";
8+ rev = "0fa417a0d2d8484e9a5a636e3301da322f586601";
9+ sha256 = "0pigcl14yc4aak6q1ghfjxdz2ah4fg4m2r5y3asw2rz6mpr5y9z0";
910 };
1011 "base" = fetchgit {
1112 url = "https://chromium.googlesource.com/chromium/src/base";
12− rev = "bc6e3ce8ca01b894751e1f7b22b561e3ae2e7f17";
13− sha256 = "1yl49v6nxbrfms52xf7fiwh7d4301m2aj744pa3hzzh989c5j6g5";
13+ rev = "ab1d7c3b92ce9c9bc756bdefb8338360d1a33a1e";
14+ sha256 = "15wis6qg9ka62k6v1vamg0bp3v5vkpapg485jsn4bbfcaqp6di0f";
1415 };
1516 "build" = fetchgit {
1617 url = "https://chromium.googlesource.com/chromium/src/build";
17− rev = "e934a19ae908081fba13769924e4ea45a7a451ce";
18− sha256 = "0jhy418vaiin7djg9zvk83f8zhasigki4442x5j7gkmgmgmyc4am";
18+ rev = "8d44c08a4c9997695db8098198bdd5026bc7a6f9";
19+ sha256 = "19sajgf55xfmvnwvy2ss7g6pyljp751cfsws30w415m6m00lmpxl";
1920 };
2021 "config" = fetchgit {
2122 url = "https://chromium.googlesource.com/chromium/src/build/config";
22− rev = "df16c6a2c070704b0a25efe46ee9af16de1e65b3";
23− sha256 = "1x18syzz1scwhd8lf448hy5lnfpq118l403x9qmwm0np318w09wg";
23+ rev = "14116c0cdcb9e28995ca8bb384a12e5c9dbd1dbb";
24+ sha256 = "04nif0lm4wcy05b7xhal023874s4r0iq067q57cgwdm72i2gml40";
2425 };
2526 "testing/gtest" = fetchgit {
2627 url = "https://chromium.googlesource.com/chromium/testing/gtest";
2728 rev = "585ec31ea716f08233a815e680fc0d4699843938";
2829 sha256 = "0csn1cza66851nmxxiw42smsm3422mx67vcyykwn0a71lcjng6rc";
2930 };
31+ "third_party/apple_apsl" = fetchurl {
32+ url = "https://chromium.googlesource.com/chromium/src/third_party/+archive/8e6ccb8c74db6dfa15dd21401ace3ac96c054cf7/apple_apsl.tar.gz";
33+ sha256 = "0sc7b7zdw7f9piyyijl7xq3v1fzflqlck1apwm8kvgdhkyz3l63k";
34+ };
3035 };
3136
32−in
33− stdenv.mkDerivation rec {
34− name = "gn";
35− version = "0.0.0.20170629";
36− sourceRoot = ".";
37+in stdenv.mkDerivation {
38+ name = "gn";
39+ version = "20180423";
40+ sourceRoot = ".";
3741
38− unpackPhase = ''
39− ${lib.concatStringsSep "\n" (
40− lib.mapAttrsToList (n: v: ''
41− mkdir -p $sourceRoot/${n}
42+ unpackPhase = ''
43+ ${lib.concatStringsSep "\n" (
44+ lib.mapAttrsToList (n: v: ''
45+ mkdir -p $sourceRoot/${n}
46+ if [ -d ${v} ]; then
4247 cp -r ${v}/* $sourceRoot/${n}
43− '') depsGit)}
44− '';
45−
46− postPatch = ''
47− # Patch shebands (for sandbox build)
48− chmod u+w -R build
49− patchShebangs build
50−
51− # Patch out Chromium-bundled libevent
52− chmod u+w tools/gn/bootstrap tools/gn/bootstrap/bootstrap.py
53− sed -i -e '/static_libraries.*libevent/,/^ *\]\?[})]$/d' \
54− tools/gn/bootstrap/bootstrap.py
55− '';
56−
57− NIX_LDFLAGS = "-levent";
58−
59− nativeBuildInputs = [ ninja python ];
60− buildInputs = [ libevent ];
61−
62− buildPhase = ''
63− python tools/gn/bootstrap/bootstrap.py -s
64− '';
65−
66− installPhase = ''
67− install -vD out/Release/gn "$out/bin/gn"
68− '';
69−
70− meta = with stdenv.lib; {
71− description = "A meta-build system that generates NinjaBuild files";
72− homepage = https://chromium.googlesource.com/chromium/src/tools/gn;
73− license = licenses.bsd3;
74− platforms = platforms.linux;
75− maintainers = [ maintainers.stesie ];
76− };
77− }
48+ else
49+ mkdir -p $sourceRoot/${n}
50+ pushd $sourceRoot/${n}
51+ unpackFile ${v}
52+ popd
53+ fi
54+ '') depsGit)}
55+
56+ chmod u+w -R $sourceRoot
57+ '';
58+
59+ patches = [
60+ (fetchpatch {
61+ url = "https://raw.githubusercontent.com/Eloston/ungoogled-chromium/master/resources/patches/ungoogled-chromium/macos/fix-gn-bootstrap.patch";
62+ sha256 = "1h8jgxznm7zrxlzb4wcfx4zx4lyvfrmpd0r7cd7h0s23wn8ibb3a";
63+ })
64+ ];
65+
66+ postPatch = ''
67+ # Disable libevent bootstrapping (we will provide it).
68+ sed -i -e '/static_libraries.*libevent/,/^ *\]\?[})]$/d' \
69+ tools/gn/bootstrap/bootstrap.py
70+
71+ # FIXME Needed with old Apple SDKs
72+ substituteInPlace base/mac/foundation_util.mm \
73+ --replace "NSArray<NSString*>*" "NSArray*"
74+ substituteInPlace base/mac/sdk_forward_declarations.h \
75+ --replace "NSDictionary<VNImageOption, id>*" "NSDictionary*" \
76+ --replace "NSArray<VNRequest*>*" "NSArray*" \
77+ --replace "typedef NSString* VNImageOption NS_STRING_ENUM" "typedef NSString* VNImageOption"
78+
79+ # Patch shebangs (for sandbox build)
80+ patchShebangs build
81+ '';
82+
83+ # FIXME again this shouldn't be necessary but I can't figure out a better way
84+ 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";
85+
86+ NIX_LDFLAGS = "-levent";
87+
88+ nativeBuildInputs = [ ninja python ];
89+ buildInputs = [ libevent ]
90+
91+ # FIXME These dependencies shouldn't be needed but can't find a way
92+ # around it. Chromium pulls this in while bootstrapping GN.
93+ ++ lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
94+ libobjc
95+ cctools
96+
97+ # frameworks
98+ ApplicationServices
99+ Foundation
100+ AppKit
101+ ImageCaptureCore
102+ CoreBluetooth
103+ IOBluetooth
104+ CoreWLAN
105+ Quartz
106+ Cocoa
107+ ]);
108+
109+ buildPhase = ''
110+ python tools/gn/bootstrap/bootstrap.py -s
111+ '';
112+
113+ installPhase = ''
114+ install -vD out/Release/gn "$out/bin/gn"
115+ '';
116+
117+ meta = with lib; {
118+ description = "A meta-build system that generates NinjaBuild files";
119+ homepage = https://chromium.googlesource.com/chromium/src/tools/gn;
120+ license = licenses.bsd3;
121+ platforms = platforms.unix;
122+ maintainers = with maintainers; [ stesie matthewbauer ];
123+ };
124+}