2016-03-20 15:57:53 +00:00
|
|
|
{ stdenv, ninja, which
|
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
|
2015-04-27 05:58:58 +01:00
|
|
|
, libpng, libxml2, libxslt, libcap
|
2014-04-01 06:36:26 +01:00
|
|
|
, xdg_utils, yasm, minizip, libwebp
|
2016-03-30 00:05:07 +01:00
|
|
|
, libusb1, pciutils, nss
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2016-10-19 09:53:27 +01: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-09-11 22:24:51 +01:00
|
|
|
, glib, gtk2, 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
|
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
|
|
|
|
, enableSELinux ? false, libselinux ? null
|
|
|
|
, enableNaCl ? false
|
2015-06-19 03:15:49 +01:00
|
|
|
, enableHotwording ? 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-09-15 23:33:25 +01:00
|
|
|
, hiDPISupport ? false
|
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;
|
|
|
|
|
|
|
|
let
|
2016-10-19 09:53:27 +01:00
|
|
|
inherit (python2Packages) python gyp ply jinja2;
|
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
# The additional attributes for creating derivations based on the chromium
|
|
|
|
# source tree.
|
|
|
|
extraAttrs = buildFun base;
|
|
|
|
|
|
|
|
mkGypFlags =
|
|
|
|
let
|
|
|
|
sanitize = value:
|
|
|
|
if value == true then "1"
|
|
|
|
else if value == false then "0"
|
|
|
|
else "${value}";
|
|
|
|
toFlag = key: value: "-D${key}=${sanitize value}";
|
|
|
|
in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs));
|
|
|
|
|
|
|
|
gypFlagsUseSystemLibs = {
|
|
|
|
use_system_bzip2 = true;
|
|
|
|
use_system_flac = true;
|
|
|
|
use_system_libevent = true;
|
|
|
|
use_system_libexpat = true;
|
2016-05-28 18:08:15 +01:00
|
|
|
# XXX: System libjpeg fails to link for version 52.0.2743.10
|
2016-06-08 05:00:25 +01:00
|
|
|
use_system_libjpeg = versionOlder upstream-info.version "52.0.2743.10";
|
2016-05-28 18:04:22 +01:00
|
|
|
use_system_libpng = false;
|
2014-04-01 06:36:26 +01:00
|
|
|
use_system_libwebp = true;
|
|
|
|
use_system_libxml = true;
|
|
|
|
use_system_opus = true;
|
|
|
|
use_system_snappy = true;
|
|
|
|
use_system_speex = true;
|
|
|
|
use_system_stlport = true;
|
|
|
|
use_system_xdg_utils = true;
|
|
|
|
use_system_yasm = true;
|
2014-03-27 08:53:01 +00:00
|
|
|
use_system_zlib = false;
|
2014-11-25 13:14:22 +00:00
|
|
|
use_system_protobuf = false; # needs newer protobuf
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
use_system_harfbuzz = false;
|
|
|
|
use_system_icu = false; # Doesn't support ICU 52 yet.
|
|
|
|
use_system_libusb = false; # http://crbug.com/266149
|
|
|
|
use_system_skia = false;
|
|
|
|
use_system_sqlite = false; # http://crbug.com/22208
|
2014-04-19 08:56:48 +01:00
|
|
|
use_system_v8 = false;
|
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
|
2015-04-27 05:58:58 +01:00
|
|
|
libpng libxml2 libxslt libcap
|
2014-04-01 06:36:26 +01:00
|
|
|
xdg_utils yasm minizip libwebp
|
2016-03-30 00:05:07 +01:00
|
|
|
libusb1
|
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}";
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
unpackCmd = ''
|
|
|
|
tar xf "$src" \
|
|
|
|
--anchored \
|
|
|
|
--no-wildcards-match-slash \
|
|
|
|
--exclude='*/tools/gyp'
|
|
|
|
'';
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
buildInputs = defaultDependencies ++ [
|
|
|
|
which
|
|
|
|
python perl pkgconfig
|
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
|
2016-09-11 22:24:51 +01:00
|
|
|
glib gtk2 dbus_glib
|
2014-04-01 06:36:26 +01:00
|
|
|
libXScrnSaver libXcursor libXtst mesa
|
|
|
|
pciutils protobuf speechd libXdamage
|
2016-10-19 09:53:27 +01:00
|
|
|
gyp ply jinja2
|
2014-04-01 06:36:26 +01:00
|
|
|
] ++ optional gnomeKeyringSupport libgnome_keyring3
|
|
|
|
++ optionals gnomeSupport [ gnome.GConf libgcrypt ]
|
|
|
|
++ optional enableSELinux libselinux
|
2014-12-07 13:52:36 +00:00
|
|
|
++ optionals cupsSupport [ libgcrypt cups ]
|
2016-05-28 18:04:22 +01:00
|
|
|
++ optional pulseSupport libpulseaudio;
|
2014-04-01 06:36:26 +01:00
|
|
|
|
2016-03-20 16:50:17 +00:00
|
|
|
patches = [
|
|
|
|
./patches/widevine.patch
|
2016-08-23 11:56:11 +01:00
|
|
|
./patches/glibc-2.24.patch
|
2016-05-28 18:08:15 +01:00
|
|
|
(if versionOlder version "52.0.0.0"
|
|
|
|
then ./patches/nix_plugin_paths_50.patch
|
|
|
|
else ./patches/nix_plugin_paths_52.patch)
|
2016-03-20 16:50:17 +00:00
|
|
|
];
|
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-03-20 16:50:17 +00:00
|
|
|
sed -i -r \
|
|
|
|
-e 's/-f(stack-protector)(-all)?/-fno-\1/' \
|
|
|
|
-e 's|/bin/echo|echo|' \
|
|
|
|
-e "/python_arch/s/: *'[^']*'/: '""'/" \
|
|
|
|
build/common.gypi chrome/chrome_tests.gypi
|
|
|
|
|
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-05-28 18:08:15 +01:00
|
|
|
'' + optionalString (versionAtLeast version "52.0.0.0") ''
|
|
|
|
sed -i -re 's/([^:])\<(isnan *\()/\1std::\2/g' \
|
|
|
|
third_party/pdfium/xfa/fxbarcode/utils.h
|
2014-04-01 06:36:26 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
gypFlags = mkGypFlags (gypFlagsUseSystemLibs // {
|
2014-08-13 03:53:31 +01:00
|
|
|
linux_use_bundled_binutils = false;
|
|
|
|
linux_use_bundled_gold = false;
|
2016-03-28 10:31:21 +01:00
|
|
|
linux_use_gold_flags = true;
|
|
|
|
|
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;
|
|
|
|
use_pulseaudio = pulseSupport;
|
2014-05-04 05:54:57 +01:00
|
|
|
linux_link_pulseaudio = pulseSupport;
|
2014-04-01 06:36:26 +01:00
|
|
|
disable_nacl = !enableNaCl;
|
2015-06-19 03:15:49 +01:00
|
|
|
enable_hotwording = enableHotwording;
|
2014-04-01 06:36:26 +01:00
|
|
|
selinux = enableSELinux;
|
|
|
|
use_cups = cupsSupport;
|
2015-01-28 07:12:51 +00:00
|
|
|
} // {
|
2014-04-01 06:36:26 +01:00
|
|
|
werror = "";
|
2014-07-28 04:05:01 +01:00
|
|
|
clang = false;
|
2014-09-15 23:33:25 +01:00
|
|
|
enable_hidpi = hiDPISupport;
|
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";
|
2014-06-16 20:35:05 +01:00
|
|
|
} // optionalAttrs (stdenv.system == "x86_64-linux") {
|
|
|
|
target_arch = "x64";
|
|
|
|
python_arch = "x86-64";
|
|
|
|
} // optionalAttrs (stdenv.system == "i686-linux") {
|
|
|
|
target_arch = "ia32";
|
|
|
|
python_arch = "ia32";
|
|
|
|
} // (extraAttrs.gypFlags or {}));
|
2014-04-01 06:36:26 +01:00
|
|
|
|
|
|
|
configurePhase = ''
|
2016-03-20 17:23:09 +00:00
|
|
|
echo "Precompiling .py files to prevent race conditions..." >&2
|
2016-03-11 16:12:16 +00:00
|
|
|
python -m compileall -q -f . > /dev/null 2>&1 || : # ignore errors
|
2014-12-24 17:09:10 +00:00
|
|
|
|
2014-04-01 06:36:26 +01:00
|
|
|
# This is to ensure expansion of $out.
|
|
|
|
libExecPath="${libExecPath}"
|
|
|
|
python build/linux/unbundle/replace_gyp_files.py ${gypFlags}
|
2015-06-11 17:23:58 +01:00
|
|
|
python build/gyp_chromium -f ninja --depth . ${gypFlags}
|
2014-04-01 06:36:26 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = let
|
2014-08-13 03:49:53 +01:00
|
|
|
buildCommand = target: ''
|
2014-08-13 03:53:31 +01:00
|
|
|
"${ninja}/bin/ninja" -C "${buildPath}" \
|
|
|
|
-j$NIX_BUILD_CORES -l$NIX_BUILD_CORES \
|
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 [
|
|
|
|
"name" "gypFlags" "buildTargets"
|
|
|
|
])
|