2018-07-21 02:44:44 +02:00
|
|
|
{ stdenv, patchelf, makeWrapper
|
2015-11-08 18:55:47 +01:00
|
|
|
|
|
|
|
# Linked dynamic libraries.
|
|
|
|
, glib, fontconfig, freetype, pango, cairo, libX11, libXi, atk, gconf, nss, nspr
|
2016-12-11 18:53:51 +01:00
|
|
|
, libXcursor, libXext, libXfixes, libXrender, libXScrnSaver, libXcomposite, libxcb
|
2015-11-08 18:55:47 +01:00
|
|
|
, alsaLib, libXdamage, libXtst, libXrandr, expat, cups
|
2019-05-22 13:03:39 +02:00
|
|
|
, dbus, gtk2, gtk3, gdk-pixbuf, gcc-unwrapped, at-spi2-atk, at-spi2-core
|
2020-02-14 00:30:21 +01:00
|
|
|
, kerberos, libdrm, mesa
|
2015-11-08 18:55:47 +01:00
|
|
|
|
2017-01-05 17:46:37 +01:00
|
|
|
# command line arguments which are always set e.g "--disable-gpu"
|
|
|
|
, commandLineArgs ? ""
|
|
|
|
|
2015-11-08 18:55:47 +01:00
|
|
|
# Will crash without.
|
2016-09-05 18:59:00 +02:00
|
|
|
, systemd
|
2015-11-08 18:55:47 +01:00
|
|
|
|
|
|
|
# Loaded at runtime.
|
|
|
|
, libexif
|
|
|
|
|
|
|
|
# Additional dependencies according to other distros.
|
|
|
|
## Ubuntu
|
|
|
|
, liberation_ttf, curl, utillinux, xdg_utils, wget
|
|
|
|
## Arch Linux.
|
|
|
|
, flac, harfbuzz, icu, libpng, libopus, snappy, speechd
|
|
|
|
## Gentoo
|
|
|
|
, bzip2, libcap
|
|
|
|
|
|
|
|
# Which distribution channel to use.
|
|
|
|
, channel ? "stable"
|
|
|
|
|
|
|
|
# Necessary for USB audio devices.
|
|
|
|
, pulseSupport ? true, libpulseaudio ? null
|
|
|
|
|
2016-05-04 23:12:33 +02:00
|
|
|
# Only needed for getting information about upstream binaries
|
|
|
|
, chromium
|
2017-06-16 07:49:50 +02:00
|
|
|
|
2018-02-25 03:23:58 +01:00
|
|
|
, gsettings-desktop-schemas
|
2017-06-16 07:49:50 +02:00
|
|
|
, gnome2, gnome3
|
2015-11-08 18:55:47 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
opusWithCustomModes = libopus.override {
|
|
|
|
withCustomModes = true;
|
|
|
|
};
|
|
|
|
|
2018-01-25 21:59:39 +01:00
|
|
|
version = chromium.upstream-info.version;
|
2017-06-16 07:49:50 +02:00
|
|
|
gtk = if (versionAtLeast version "59.0.0.0") then gtk3 else gtk2;
|
|
|
|
gnome = if (versionAtLeast version "59.0.0.0") then gnome3 else gnome2;
|
|
|
|
|
2016-04-14 18:53:13 +02:00
|
|
|
deps = [
|
|
|
|
glib fontconfig freetype pango cairo libX11 libXi atk gconf nss nspr
|
2016-12-11 18:53:51 +01:00
|
|
|
libXcursor libXext libXfixes libXrender libXScrnSaver libXcomposite libxcb
|
2016-04-14 18:53:13 +02:00
|
|
|
alsaLib libXdamage libXtst libXrandr expat cups
|
2019-05-22 13:03:39 +02:00
|
|
|
dbus gdk-pixbuf gcc-unwrapped.lib
|
2016-09-05 18:59:00 +02:00
|
|
|
systemd
|
2016-04-14 18:53:13 +02:00
|
|
|
libexif
|
|
|
|
liberation_ttf curl utillinux xdg_utils wget
|
|
|
|
flac harfbuzz icu libpng opusWithCustomModes snappy speechd
|
2018-11-02 10:01:36 +01:00
|
|
|
bzip2 libcap at-spi2-atk at-spi2-core
|
2020-02-15 19:51:35 +01:00
|
|
|
kerberos libdrm mesa
|
2017-04-15 15:35:42 +02:00
|
|
|
] ++ optional pulseSupport libpulseaudio
|
2017-06-16 07:49:50 +02:00
|
|
|
++ [ gtk ];
|
2016-12-27 17:21:56 +01:00
|
|
|
|
|
|
|
suffix = if channel != "stable" then "-" + channel else "";
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
in stdenv.mkDerivation {
|
2015-11-08 18:55:47 +01:00
|
|
|
inherit version;
|
|
|
|
|
2016-12-27 17:21:56 +01:00
|
|
|
name = "google-chrome${suffix}-${version}";
|
2015-11-08 18:55:47 +01:00
|
|
|
|
2018-01-25 21:59:39 +01:00
|
|
|
src = chromium.upstream-info.binary;
|
2015-11-08 18:55:47 +01:00
|
|
|
|
2018-09-27 23:28:19 +02:00
|
|
|
nativeBuildInputs = [ patchelf makeWrapper ];
|
2017-06-16 07:49:50 +02:00
|
|
|
buildInputs = [
|
|
|
|
# needed for GSETTINGS_SCHEMAS_PATH
|
2018-02-25 03:23:58 +01:00
|
|
|
gsettings-desktop-schemas glib gtk
|
2017-06-16 07:49:50 +02:00
|
|
|
|
|
|
|
# needed for XDG_ICON_DIRS
|
2019-02-13 22:47:50 +01:00
|
|
|
gnome.adwaita-icon-theme
|
2017-06-16 07:49:50 +02:00
|
|
|
];
|
2015-11-08 18:55:47 +01:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
ar x $src
|
|
|
|
tar xf data.tar.xz
|
|
|
|
'';
|
|
|
|
|
2016-04-14 17:14:28 +02:00
|
|
|
rpath = makeLibraryPath deps + ":" + makeSearchPathOutput "lib" "lib64" deps;
|
2016-04-14 18:53:13 +02:00
|
|
|
binpath = makeBinPath deps;
|
|
|
|
|
2015-11-08 18:55:47 +01:00
|
|
|
installPhase = ''
|
2015-12-28 09:31:48 +01:00
|
|
|
case ${channel} in
|
|
|
|
beta) appname=chrome-beta dist=beta ;;
|
|
|
|
dev) appname=chrome-unstable dist=unstable ;;
|
|
|
|
*) appname=chrome dist=stable ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exe=$out/bin/google-chrome-$dist
|
2015-11-08 18:55:47 +01:00
|
|
|
|
|
|
|
mkdir -p $out/bin $out/share
|
|
|
|
|
|
|
|
cp -a opt/* $out/share
|
|
|
|
cp -a usr/share/* $out/share
|
|
|
|
|
2015-12-28 09:31:48 +01:00
|
|
|
substituteInPlace $out/share/applications/google-$appname.desktop \
|
|
|
|
--replace /usr/bin/google-chrome-$dist $exe
|
|
|
|
substituteInPlace $out/share/gnome-control-center/default-apps/google-$appname.xml \
|
|
|
|
--replace /opt/google/$appname/google-$appname $exe
|
|
|
|
substituteInPlace $out/share/menu/google-$appname.menu \
|
2015-11-08 18:55:47 +01:00
|
|
|
--replace /opt $out/share \
|
2015-12-28 09:31:48 +01:00
|
|
|
--replace $out/share/google/chrome/google-$appname $exe
|
2015-11-08 18:55:47 +01:00
|
|
|
|
2015-12-28 09:31:48 +01:00
|
|
|
for icon_file in $out/share/google/chrome*/product_logo_*[0-9].png; do
|
2015-11-08 18:55:47 +01:00
|
|
|
num_and_suffix="''${icon_file##*logo_}"
|
|
|
|
icon_size="''${num_and_suffix%.*}"
|
|
|
|
logo_output_prefix="$out/share/icons/hicolor"
|
|
|
|
logo_output_path="$logo_output_prefix/''${icon_size}x''${icon_size}/apps"
|
|
|
|
mkdir -p "$logo_output_path"
|
2015-12-28 09:31:48 +01:00
|
|
|
mv "$icon_file" "$logo_output_path/google-$appname.png"
|
2015-11-08 18:55:47 +01:00
|
|
|
done
|
|
|
|
|
2018-03-06 14:00:14 +01:00
|
|
|
makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$rpath" \
|
|
|
|
--prefix PATH : "$binpath" \
|
|
|
|
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
|
|
|
|
--add-flags ${escapeShellArg commandLineArgs}
|
2015-11-08 18:55:47 +01:00
|
|
|
|
2015-12-28 09:31:48 +01:00
|
|
|
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,nacl_helper}; do
|
2015-11-08 18:55:47 +01:00
|
|
|
patchelf --set-rpath $rpath $elf
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $elf
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A freeware web browser developed by Google";
|
2015-12-28 09:31:48 +01:00
|
|
|
homepage = https://www.google.com/chrome/browser/;
|
2015-11-08 18:55:47 +01:00
|
|
|
license = licenses.unfree;
|
|
|
|
maintainers = [ maintainers.msteen ];
|
2017-12-06 07:21:53 +01:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2015-11-08 18:55:47 +01:00
|
|
|
};
|
|
|
|
}
|