2015-11-08 17:55:47 +00:00
|
|
|
{ stdenv, buildEnv, fetchurl, patchelf, bash
|
|
|
|
|
|
|
|
# Linked dynamic libraries.
|
|
|
|
, glib, fontconfig, freetype, pango, cairo, libX11, libXi, atk, gconf, nss, nspr
|
|
|
|
, libXcursor, libXext, libXfixes, libXrender, libXScrnSaver, libXcomposite
|
|
|
|
, alsaLib, libXdamage, libXtst, libXrandr, expat, cups
|
|
|
|
, dbus_libs, gtk, gdk_pixbuf, gcc
|
|
|
|
|
|
|
|
# Will crash without.
|
2016-04-14 17:53:13 +01:00
|
|
|
, libudev
|
2015-11-08 17:55:47 +00: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
|
|
|
|
|
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
2016-03-21 11:03:50 +00:00
|
|
|
with (import ../chromium/update.nix {
|
2015-11-08 17:55:47 +00:00
|
|
|
inherit (stdenv) system;
|
|
|
|
}).getChannel channel;
|
|
|
|
|
|
|
|
let
|
|
|
|
opusWithCustomModes = libopus.override {
|
|
|
|
withCustomModes = true;
|
|
|
|
};
|
|
|
|
|
2016-04-14 17:53:13 +01:00
|
|
|
deps = [
|
|
|
|
stdenv.cc.cc
|
|
|
|
glib fontconfig freetype pango cairo libX11 libXi atk gconf nss nspr
|
|
|
|
libXcursor libXext libXfixes libXrender libXScrnSaver libXcomposite
|
|
|
|
alsaLib libXdamage libXtst libXrandr expat cups
|
|
|
|
dbus_libs gtk gdk_pixbuf gcc
|
|
|
|
libudev
|
|
|
|
libexif
|
|
|
|
liberation_ttf curl utillinux xdg_utils wget
|
|
|
|
flac harfbuzz icu libpng opusWithCustomModes snappy speechd
|
|
|
|
bzip2 libcap
|
|
|
|
] ++ optional pulseSupport libpulseaudio;
|
2015-11-08 17:55:47 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
name = "google-chrome-${version}";
|
|
|
|
|
2016-03-21 15:11:23 +00:00
|
|
|
src = binary;
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2016-04-14 17:53:13 +01:00
|
|
|
buildInputs = [ patchelf ];
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
ar x $src
|
|
|
|
tar xf data.tar.xz
|
|
|
|
'';
|
|
|
|
|
2016-04-14 18:00:15 +01:00
|
|
|
rpath = makeLibraryPath deps + ":" + makeSearchPathOutputs "lib64" ["lib"] deps;
|
2016-04-14 17:53:13 +01:00
|
|
|
binpath = makeBinPath deps;
|
|
|
|
|
2015-11-08 17:55:47 +00:00
|
|
|
installPhase = ''
|
2015-12-28 08:31:48 +00: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 17:55:47 +00:00
|
|
|
|
|
|
|
mkdir -p $out/bin $out/share
|
|
|
|
|
|
|
|
cp -a opt/* $out/share
|
|
|
|
cp -a usr/share/* $out/share
|
|
|
|
|
2015-12-28 08:31:48 +00: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 17:55:47 +00:00
|
|
|
--replace /opt $out/share \
|
2015-12-28 08:31:48 +00:00
|
|
|
--replace $out/share/google/chrome/google-$appname $exe
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2015-12-28 08:31:48 +00:00
|
|
|
for icon_file in $out/share/google/chrome*/product_logo_*[0-9].png; do
|
2015-11-08 17:55:47 +00: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 08:31:48 +00:00
|
|
|
mv "$icon_file" "$logo_output_path/google-$appname.png"
|
2015-11-08 17:55:47 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
cat > $exe << EOF
|
|
|
|
#!${bash}/bin/sh
|
|
|
|
export LD_LIBRARY_PATH=$rpath\''${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
|
2016-04-14 17:53:13 +01:00
|
|
|
export PATH=$binpath\''${PATH:+:\$PATH}
|
2015-12-28 08:31:48 +00:00
|
|
|
$out/share/google/$appname/google-$appname "\$@"
|
2015-11-08 17:55:47 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $exe
|
|
|
|
|
2015-12-28 08:31:48 +00:00
|
|
|
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,nacl_helper}; do
|
2015-11-08 17:55:47 +00: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 08:31:48 +00:00
|
|
|
homepage = https://www.google.com/chrome/browser/;
|
2015-11-08 17:55:47 +00:00
|
|
|
license = licenses.unfree;
|
|
|
|
maintainers = [ maintainers.msteen ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|