2017-02-08 19:40:39 +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-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
|
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;
|
|
|
|
|
|
|
|
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 = [
|
2016-10-29 13:28:06 +01:00
|
|
|
"flac" "libwebp" "libxml" "libxslt" "snappy" "yasm"
|
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
|
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-10-29 13:28:06 +01:00
|
|
|
libusb1 re2 zlib
|
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;
|
|
|
|
|
2017-02-08 19:47:07 +00:00
|
|
|
nativeBuildInputs = [
|
2017-02-08 19:40:39 +00:00
|
|
|
ninja which python2Packages.python perl pkgconfig
|
2017-02-08 19:47:07 +00:00
|
|
|
python2Packages.ply python2Packages.jinja2
|
|
|
|
];
|
|
|
|
|
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
|
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
|
|
|
|
] ++ optional gnomeKeyringSupport libgnome_keyring3
|
|
|
|
++ optionals gnomeSupport [ gnome.GConf libgcrypt ]
|
2014-12-07 13:52:36 +00:00
|
|
|
++ optionals cupsSupport [ libgcrypt cups ]
|
2016-11-08 20:19:49 +00:00
|
|
|
++ optional pulseSupport libpulseaudio
|
|
|
|
++ optional (versionAtLeast version "56.0.0.0") gtk3;
|
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-05-12 12:22:39 +01:00
|
|
|
./patches/fix-bootstrap-gn.patch
|
2017-02-08 19:42:42 +00:00
|
|
|
] ++ optional (versionOlder version "57.0") ./patches/glibc-2.24.patch
|
|
|
|
++ 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
|
|
|
|
|
|
|
|
patchShebangs .
|
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
|
|
|
'';
|
|
|
|
|
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;
|
2015-01-28 07:12:51 +00:00
|
|
|
} // {
|
2016-10-29 03:05:53 +01:00
|
|
|
treat_warnings_as_errors = false;
|
|
|
|
is_clang = false;
|
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
|
2014-08-13 03:49:53 +01:00
|
|
|
buildCommand = target: ''
|
2017-02-08 19:47:07 +00:00
|
|
|
ninja -C "${buildPath}" \
|
2014-08-13 03:53:31 +01:00
|
|
|
-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 [
|
2016-10-29 03:05:53 +01:00
|
|
|
"name" "gnFlags" "buildTargets"
|
2014-04-01 06:36:26 +01:00
|
|
|
])
|