2017-07-06 23:54:10 +01:00
|
|
|
{ stdenv, ninja, which, nodejs, fetchurl, gnutar
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
# default dependencies
|
2015-06-11 17:23:58 +01:00
|
|
|
, bzip2, flac, speex, libopus
|
2014-04-01 06:36:26 +01:00
|
|
|
, libevent, expat, libjpeg, snappy
|
2017-06-11 09:10:56 +01:00
|
|
|
, libpng, libcap
|
2014-04-01 06:36:26 +01:00
|
|
|
, xdg_utils, yasm, minizip, libwebp
|
2016-10-29 03:05:53 +01:00
|
|
|
, libusb1, pciutils, nss, re2, zlib, libvpx
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2016-11-19 09:29:45 +00:00
|
|
|
, python2Packages, perl, pkgconfig
|
2016-09-05 17:59:00 +01:00
|
|
|
, nspr, systemd, kerberos
|
2014-04-01 06:36:26 +01:00
|
|
|
, utillinux, alsaLib
|
2014-08-13 03:53:31 +01:00
|
|
|
, bison, gperf
|
2016-11-08 20:19:49 +00:00
|
|
|
, glib, gtk2, gtk3, dbus_glib
|
2014-04-01 06:36:26 +01:00
|
|
|
, libXScrnSaver, libXcursor, libXtst, mesa
|
2014-12-07 13:52:36 +00:00
|
|
|
, protobuf, speechd, libXdamage, cups
|
2017-07-06 23:54:10 +01:00
|
|
|
, ffmpeg, harfbuzz, harfbuzz-icu, libxslt, libxml2
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
# optional dependencies
|
|
|
|
, libgcrypt ? null # gnomeSupport || cupsSupport
|
2016-03-30 00:05:07 +01:00
|
|
|
, libexif ? null # only needed for Chromium before version 51
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
# package customization
|
|
|
|
, enableNaCl ? false
|
2015-06-19 03:15:49 +01:00
|
|
|
, enableHotwording ? false
|
2016-11-08 19:18:15 +00:00
|
|
|
, enableWideVine ? false
|
2014-04-01 06:36:26 +01:00
|
|
|
, gnomeSupport ? false, gnome ? null
|
|
|
|
, gnomeKeyringSupport ? false, libgnome_keyring3 ? null
|
|
|
|
, proprietaryCodecs ? true
|
2014-12-07 13:52:36 +00:00
|
|
|
, cupsSupport ? true
|
2015-05-27 20:42:15 +01:00
|
|
|
, pulseSupport ? false, libpulseaudio ? null
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2016-03-20 16:50:17 +00:00
|
|
|
, upstream-info
|
2014-04-01 06:36:26 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildFun:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
2017-07-06 23:54:10 +01:00
|
|
|
# see http://www.linuxfromscratch.org/blfs/view/cvs/xsoft/chromium.html
|
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
let
|
|
|
|
# The additional attributes for creating derivations based on the chromium
|
|
|
|
# source tree.
|
|
|
|
extraAttrs = buildFun base;
|
|
|
|
|
2016-10-29 03:05:53 +01:00
|
|
|
mkGnFlags =
|
2014-04-01 06:36:26 +01:00
|
|
|
let
|
2016-10-29 03:05:53 +01:00
|
|
|
# Serialize Nix types into GN types according to this document:
|
|
|
|
# https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/language.md
|
|
|
|
mkGnString = value: "\"${escape ["\"" "$" "\\"] value}\"";
|
2014-04-01 06:36:26 +01:00
|
|
|
sanitize = value:
|
2016-10-29 03:05:53 +01:00
|
|
|
if value == true then "true"
|
|
|
|
else if value == false then "false"
|
|
|
|
else if isList value then "[${concatMapStringsSep ", " sanitize value}]"
|
|
|
|
else if isInt value then toString value
|
|
|
|
else if isString value then mkGnString value
|
|
|
|
else throw "Unsupported type for GN value `${value}'.";
|
|
|
|
toFlag = key: value: "${key}=${sanitize value}";
|
2014-04-01 06:36:26 +01:00
|
|
|
in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs));
|
|
|
|
|
2016-10-29 03:05:53 +01:00
|
|
|
gnSystemLibraries = [
|
2017-07-31 09:01:15 +01:00
|
|
|
"flac" "harfbuzz-ng" "libwebp" "libxslt" "yasm" "opus" "snappy" "libpng" "zlib"
|
|
|
|
# "libjpeg" # fails with multiple undefined references to chromium_jpeg_*
|
|
|
|
# "re2" # fails with linker errors
|
|
|
|
# "ffmpeg" # https://crbug.com/731766
|
2016-10-29 03:05:53 +01:00
|
|
|
];
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
opusWithCustomModes = libopus.override {
|
2014-07-28 04:05:01 +01:00
|
|
|
withCustomModes = true;
|
2014-04-01 06:36:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
defaultDependencies = [
|
2015-06-11 17:23:58 +01:00
|
|
|
bzip2 flac speex opusWithCustomModes
|
2014-04-01 06:36:26 +01:00
|
|
|
libevent expat libjpeg snappy
|
2017-06-11 09:10:56 +01:00
|
|
|
libpng libcap
|
2014-04-01 06:36:26 +01:00
|
|
|
xdg_utils yasm minizip libwebp
|
2016-10-29 13:28:06 +01:00
|
|
|
libusb1 re2 zlib
|
2017-07-31 09:01:15 +01:00
|
|
|
ffmpeg harfbuzz-icu libxslt libxml2
|
2014-04-01 06:36:26 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# build paths and release info
|
2014-04-20 07:39:40 +01:00
|
|
|
packageName = extraAttrs.packageName or extraAttrs.name;
|
2014-04-01 06:36:26 +01:00
|
|
|
buildType = "Release";
|
|
|
|
buildPath = "out/${buildType}";
|
|
|
|
libExecPath = "$out/libexec/${packageName}";
|
|
|
|
|
2017-07-06 23:54:10 +01:00
|
|
|
freetype_source = fetchurl {
|
|
|
|
url = http://anduin.linuxfromscratch.org/BLFS/other/chromium-freetype.tar.xz;
|
|
|
|
sha256 = "1vhslc4xg0d6wzlsi99zpah2xzjziglccrxn55k7qna634wyxg77";
|
|
|
|
};
|
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
base = rec {
|
|
|
|
name = "${packageName}-${version}";
|
2016-03-20 16:50:17 +00:00
|
|
|
inherit (upstream-info) version;
|
2014-04-01 06:36:26 +01:00
|
|
|
inherit packageName buildType buildPath;
|
2016-03-20 16:50:17 +00:00
|
|
|
|
|
|
|
src = upstream-info.main;
|
|
|
|
|
2017-02-08 19:47:07 +00:00
|
|
|
nativeBuildInputs = [
|
2017-02-08 19:40:39 +00:00
|
|
|
ninja which python2Packages.python perl pkgconfig
|
2017-05-14 14:03:21 +01:00
|
|
|
python2Packages.ply python2Packages.jinja2 nodejs
|
2017-07-06 23:54:10 +01:00
|
|
|
gnutar
|
2017-02-08 19:47:07 +00:00
|
|
|
];
|
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
buildInputs = defaultDependencies ++ [
|
2016-09-05 17:59:00 +01:00
|
|
|
nspr nss systemd
|
2014-04-01 06:36:26 +01:00
|
|
|
utillinux alsaLib
|
2014-12-30 08:05:12 +00:00
|
|
|
bison gperf kerberos
|
2017-07-31 08:52:45 +01:00
|
|
|
glib gtk2 gtk3 dbus_glib
|
2014-04-01 06:36:26 +01:00
|
|
|
libXScrnSaver libXcursor libXtst mesa
|
|
|
|
pciutils protobuf speechd libXdamage
|
|
|
|
] ++ optional gnomeKeyringSupport libgnome_keyring3
|
|
|
|
++ optionals gnomeSupport [ gnome.GConf libgcrypt ]
|
2014-12-07 13:52:36 +00:00
|
|
|
++ optionals cupsSupport [ libgcrypt cups ]
|
2017-07-31 08:52:45 +01:00
|
|
|
++ optional pulseSupport libpulseaudio;
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2016-03-20 16:50:17 +00:00
|
|
|
patches = [
|
2016-10-10 09:56:22 +01:00
|
|
|
./patches/nix_plugin_paths_52.patch
|
2017-09-12 14:13:03 +01:00
|
|
|
./patches/chromium-gn-bootstrap-r14.patch
|
|
|
|
./patches/chromium-gcc-r1.patch
|
|
|
|
./patches/chromium-atk-r1.patch
|
|
|
|
./patches/chromium-gcc5-r1.patch
|
2017-06-17 16:22:13 +01:00
|
|
|
# To enable ChromeCast, go to chrome://flags and set "Load Media Router Component Extension" to Enabled
|
|
|
|
# Fixes Chromecast: https://bugs.chromium.org/p/chromium/issues/detail?id=734325
|
|
|
|
./patches/fix_network_api_crash.patch
|
2017-07-31 08:52:45 +01:00
|
|
|
|
|
|
|
] ++ optional enableWideVine ./patches/widevine.patch;
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2015-06-19 18:35:30 +01:00
|
|
|
postPatch = ''
|
2016-08-04 20:26:05 +01:00
|
|
|
# We want to be able to specify where the sandbox is via CHROME_DEVEL_SANDBOX
|
|
|
|
substituteInPlace sandbox/linux/suid/client/setuid_sandbox_host.cc \
|
|
|
|
--replace \
|
2016-08-05 10:55:48 +01:00
|
|
|
'return sandbox_binary;' \
|
|
|
|
'return base::FilePath(GetDevelSandboxPath());'
|
2016-08-04 20:26:05 +01:00
|
|
|
|
2016-09-05 17:59:00 +01:00
|
|
|
sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${systemd.lib}/lib/\1!' \
|
2015-01-23 00:48:56 +00:00
|
|
|
device/udev_linux/udev?_loader.cc
|
|
|
|
|
|
|
|
sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
|
|
|
|
gpu/config/gpu_info_collector_linux.cc
|
2016-05-28 18:04:22 +01:00
|
|
|
|
2016-03-30 00:05:07 +01:00
|
|
|
sed -i -re 's/([^:])\<(isnan *\()/\1std::\2/g' \
|
|
|
|
chrome/browser/ui/webui/engagement/site_engagement_ui.cc
|
2016-10-29 03:05:53 +01:00
|
|
|
|
|
|
|
sed -i -e '/#include/ {
|
|
|
|
i #include <algorithm>
|
|
|
|
:l; n; bl
|
|
|
|
}' gpu/config/gpu_control_list.cc
|
|
|
|
|
2017-06-18 03:29:22 +01:00
|
|
|
# Allow to put extensions into the system-path.
|
|
|
|
sed -i -e 's,/usr,/run/current-system/sw,' chrome/common/chrome_paths.cc
|
|
|
|
|
2016-10-29 03:05:53 +01:00
|
|
|
patchShebangs .
|
2017-05-14 14:03:21 +01:00
|
|
|
# use our own nodejs
|
|
|
|
mkdir -p third_party/node/linux/node-linux-x64/bin
|
|
|
|
ln -s $(which node) third_party/node/linux/node-linux-x64/bin/node
|
2017-07-06 23:54:10 +01:00
|
|
|
|
|
|
|
# use patched freetype
|
|
|
|
# FIXME https://bugs.chromium.org/p/pdfium/issues/detail?id=733
|
|
|
|
# FIXME http://savannah.nongnu.org/bugs/?51156
|
|
|
|
tar -xJf ${freetype_source}
|
|
|
|
|
|
|
|
# remove unused third-party
|
|
|
|
for lib in ${toString gnSystemLibraries}; do
|
|
|
|
find -type f -path "*third_party/$lib/*" \
|
|
|
|
\! -path "*third_party/$lib/chromium/*" \
|
|
|
|
\! -path "*third_party/$lib/google/*" \
|
|
|
|
\! -path "*base/third_party/icu/*" \
|
|
|
|
\! -path "*base/third_party/libevent/*" \
|
|
|
|
\! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
|
|
|
|
-delete
|
|
|
|
done
|
2014-04-01 06:36:26 +01:00
|
|
|
'';
|
|
|
|
|
2016-10-29 03:05:53 +01:00
|
|
|
gnFlags = mkGnFlags ({
|
2014-08-13 03:53:31 +01:00
|
|
|
linux_use_bundled_binutils = false;
|
2017-02-08 19:42:06 +00:00
|
|
|
use_gold = true;
|
|
|
|
gold_path = "${stdenv.cc}/bin";
|
2016-10-29 03:05:53 +01:00
|
|
|
is_debug = false;
|
2016-03-28 10:31:21 +01:00
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
proprietary_codecs = false;
|
2015-12-29 18:32:30 +00:00
|
|
|
use_sysroot = false;
|
2014-04-01 06:36:26 +01:00
|
|
|
use_gnome_keyring = gnomeKeyringSupport;
|
|
|
|
use_gconf = gnomeSupport;
|
|
|
|
use_gio = gnomeSupport;
|
2016-10-29 03:05:53 +01:00
|
|
|
enable_nacl = enableNaCl;
|
2015-06-19 03:15:49 +01:00
|
|
|
enable_hotwording = enableHotwording;
|
2016-11-08 19:18:15 +00:00
|
|
|
enable_widevine = enableWideVine;
|
2014-04-01 06:36:26 +01:00
|
|
|
use_cups = cupsSupport;
|
2017-07-31 09:01:15 +01:00
|
|
|
|
2016-10-29 03:05:53 +01:00
|
|
|
treat_warnings_as_errors = false;
|
|
|
|
is_clang = false;
|
2017-07-31 09:01:15 +01:00
|
|
|
clang_use_chrome_plugins = false;
|
|
|
|
remove_webcore_debug_symbols = true;
|
|
|
|
use_gtk3 = true;
|
|
|
|
enable_swiftshader = false;
|
|
|
|
fieldtrial_testing_like_official_build = true;
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2014-04-19 14:25:21 +01:00
|
|
|
# Google API keys, see:
|
|
|
|
# http://www.chromium.org/developers/how-tos/api-keys
|
2014-04-01 06:36:26 +01:00
|
|
|
# Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
|
|
|
|
# please get your own set of keys.
|
|
|
|
google_api_key = "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI";
|
|
|
|
google_default_client_id = "404761575300.apps.googleusercontent.com";
|
|
|
|
google_default_client_secret = "9rIFQjfnkykEmqb6FfjJQD1D";
|
|
|
|
} // optionalAttrs proprietaryCodecs {
|
|
|
|
# enable support for the H.264 codec
|
|
|
|
proprietary_codecs = true;
|
2015-10-07 17:42:24 +01:00
|
|
|
enable_hangout_services_extension = true;
|
2014-04-01 06:36:26 +01:00
|
|
|
ffmpeg_branding = "Chrome";
|
2016-10-29 03:05:53 +01:00
|
|
|
} // optionalAttrs pulseSupport {
|
|
|
|
use_pulseaudio = true;
|
|
|
|
link_pulseaudio = true;
|
|
|
|
} // (extraAttrs.gnFlags or {}));
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
configurePhase = ''
|
2017-02-08 19:48:05 +00:00
|
|
|
runHook preConfigure
|
|
|
|
|
2017-02-08 19:40:39 +00:00
|
|
|
# Build gn
|
|
|
|
python tools/gn/bootstrap/bootstrap.py -v -s --no-clean
|
|
|
|
PATH="$PWD/out/Release:$PATH"
|
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
# This is to ensure expansion of $out.
|
|
|
|
libExecPath="${libExecPath}"
|
2016-10-29 03:05:53 +01:00
|
|
|
python build/linux/unbundle/replace_gn_files.py \
|
|
|
|
--system-libraries ${toString gnSystemLibraries}
|
|
|
|
gn gen --args=${escapeShellArg gnFlags} out/Release
|
2017-02-08 19:48:05 +00:00
|
|
|
|
|
|
|
runHook postConfigure
|
2014-04-01 06:36:26 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = let
|
2017-09-01 11:24:47 +01:00
|
|
|
# Build paralelism: on Hydra the build was frequently running into memory
|
|
|
|
# exhaustion, and even other users might be running into similar issues.
|
|
|
|
# -j is halved to avoid memory problems, and -l is slightly increased
|
|
|
|
# so that the build gets slight preference before others
|
|
|
|
# (it will often be on "critical path" and at risk of timing out)
|
2014-08-13 03:49:53 +01:00
|
|
|
buildCommand = target: ''
|
2017-02-08 19:47:07 +00:00
|
|
|
ninja -C "${buildPath}" \
|
2017-09-01 11:24:47 +01:00
|
|
|
-j$(( ($NIX_BUILD_CORES+1) / 2 )) -l$(( $NIX_BUILD_CORES+1 )) \
|
2014-08-13 03:49:53 +01:00
|
|
|
"${target}"
|
2014-06-16 20:35:05 +01:00
|
|
|
'' + optionalString (target == "mksnapshot" || target == "chrome") ''
|
2014-08-13 03:49:53 +01:00
|
|
|
paxmark m "${buildPath}/${target}"
|
2014-04-25 02:58:33 +01:00
|
|
|
'';
|
|
|
|
targets = extraAttrs.buildTargets or [];
|
|
|
|
commands = map buildCommand targets;
|
|
|
|
in concatStringsSep "\n" commands;
|
2014-04-01 06:36:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Remove some extraAttrs we supplied to the base attributes already.
|
|
|
|
in stdenv.mkDerivation (base // removeAttrs extraAttrs [
|
2016-10-29 03:05:53 +01:00
|
|
|
"name" "gnFlags" "buildTargets"
|
2014-04-01 06:36:26 +01:00
|
|
|
])
|