2021-01-15 05:42:41 +00:00
|
|
|
{ lib, stdenv, patchelf, makeWrapper
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
# Linked dynamic libraries.
|
2022-02-11 14:02:33 +00:00
|
|
|
, glib, fontconfig, freetype, pango, cairo, libX11, libXi, atk, nss, nspr
|
2016-12-11 17:53:51 +00:00
|
|
|
, libXcursor, libXext, libXfixes, libXrender, libXScrnSaver, libXcomposite, libxcb
|
2021-06-10 03:57:09 +01:00
|
|
|
, alsa-lib, libXdamage, libXtst, libXrandr, libxshmfence, expat, cups
|
2020-11-29 10:19:42 +00:00
|
|
|
, dbus, gtk3, gdk-pixbuf, gcc-unwrapped, at-spi2-atk, at-spi2-core
|
2022-01-19 19:50:11 +00:00
|
|
|
, libkrb5, libdrm, libglvnd, mesa
|
2021-09-25 10:32:58 +01:00
|
|
|
, libxkbcommon, pipewire, wayland # ozone/wayland
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2020-06-17 13:32:34 +01:00
|
|
|
# Command line programs
|
|
|
|
, coreutils
|
|
|
|
|
2017-01-05 16:46:37 +00:00
|
|
|
# command line arguments which are always set e.g "--disable-gpu"
|
|
|
|
, commandLineArgs ? ""
|
|
|
|
|
2015-11-08 17:55:47 +00:00
|
|
|
# Will crash without.
|
2016-09-05 17:59:00 +01:00
|
|
|
, systemd
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
# Loaded at runtime.
|
2021-07-25 08:53:56 +01:00
|
|
|
, libexif, pciutils
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
# Additional dependencies according to other distros.
|
|
|
|
## Ubuntu
|
2021-02-01 08:05:09 +00:00
|
|
|
, liberation_ttf, curl, util-linux, xdg-utils, wget
|
2015-11-08 17:55:47 +00:00
|
|
|
## 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 22:12:33 +01:00
|
|
|
# Only needed for getting information about upstream binaries
|
|
|
|
, chromium
|
2017-06-16 06:49:50 +01:00
|
|
|
|
2018-02-25 02:23:58 +00:00
|
|
|
, gsettings-desktop-schemas
|
2021-05-07 22:18:14 +01:00
|
|
|
, gnome
|
2021-03-11 20:24:47 +00:00
|
|
|
|
|
|
|
# For video acceleration via VA-API (--enable-features=VaapiVideoDecoder)
|
|
|
|
, libvaSupport ? true, libva
|
2021-03-12 17:50:36 +00:00
|
|
|
|
|
|
|
# For Vulkan support (--enable-features=Vulkan)
|
2022-01-18 08:16:04 +00:00
|
|
|
, addOpenGLRunpath
|
2015-11-08 17:55:47 +00:00
|
|
|
}:
|
|
|
|
|
2021-01-15 05:42:41 +00:00
|
|
|
with lib;
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
opusWithCustomModes = libopus.override {
|
|
|
|
withCustomModes = true;
|
|
|
|
};
|
|
|
|
|
2018-01-25 20:59:39 +00:00
|
|
|
version = chromium.upstream-info.version;
|
2017-06-16 06:49:50 +01:00
|
|
|
|
2016-04-14 17:53:13 +01:00
|
|
|
deps = [
|
2022-02-11 14:02:33 +00:00
|
|
|
glib fontconfig freetype pango cairo libX11 libXi atk nss nspr
|
2016-12-11 17:53:51 +00:00
|
|
|
libXcursor libXext libXfixes libXrender libXScrnSaver libXcomposite libxcb
|
2021-06-10 03:57:09 +01:00
|
|
|
alsa-lib libXdamage libXtst libXrandr libxshmfence expat cups
|
2019-05-22 12:03:39 +01:00
|
|
|
dbus gdk-pixbuf gcc-unwrapped.lib
|
2016-09-05 17:59:00 +01:00
|
|
|
systemd
|
2021-07-25 08:53:56 +01:00
|
|
|
libexif pciutils
|
2021-02-01 08:05:09 +00:00
|
|
|
liberation_ttf curl util-linux xdg-utils wget
|
2016-04-14 17:53:13 +01:00
|
|
|
flac harfbuzz icu libpng opusWithCustomModes snappy speechd
|
2018-11-02 09:01:36 +00:00
|
|
|
bzip2 libcap at-spi2-atk at-spi2-core
|
2022-01-19 19:50:11 +00:00
|
|
|
libkrb5 libdrm libglvnd mesa coreutils
|
2021-09-25 10:32:58 +01:00
|
|
|
libxkbcommon pipewire wayland
|
2017-04-15 14:35:42 +01:00
|
|
|
] ++ optional pulseSupport libpulseaudio
|
2021-03-11 20:24:47 +00:00
|
|
|
++ optional libvaSupport libva
|
2020-11-29 10:19:42 +00:00
|
|
|
++ [ gtk3 ];
|
2016-12-27 16:21:56 +00:00
|
|
|
|
|
|
|
suffix = if channel != "stable" then "-" + channel else "";
|
|
|
|
|
2021-08-20 12:48:07 +01:00
|
|
|
crashpadHandlerBinary = if lib.versionAtLeast version "94"
|
|
|
|
then "chrome_crashpad_handler"
|
|
|
|
else "crashpad_handler";
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
in stdenv.mkDerivation {
|
2015-11-08 17:55:47 +00:00
|
|
|
inherit version;
|
|
|
|
|
2016-12-27 16:21:56 +00:00
|
|
|
name = "google-chrome${suffix}-${version}";
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2019-11-06 19:37:25 +00:00
|
|
|
src = chromium.chromeSrc;
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2018-09-27 22:28:19 +01:00
|
|
|
nativeBuildInputs = [ patchelf makeWrapper ];
|
2017-06-16 06:49:50 +01:00
|
|
|
buildInputs = [
|
|
|
|
# needed for GSETTINGS_SCHEMAS_PATH
|
2020-11-29 10:19:42 +00:00
|
|
|
gsettings-desktop-schemas glib gtk3
|
2017-06-16 06:49:50 +01:00
|
|
|
|
|
|
|
# needed for XDG_ICON_DIRS
|
2021-05-07 22:18:14 +01:00
|
|
|
gnome.adwaita-icon-theme
|
2017-06-16 06:49:50 +01:00
|
|
|
];
|
2015-11-08 17:55:47 +00:00
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
ar x $src
|
|
|
|
tar xf data.tar.xz
|
|
|
|
'';
|
|
|
|
|
2016-04-14 16:14:28 +01:00
|
|
|
rpath = makeLibraryPath deps + ":" + makeSearchPathOutput "lib" "lib64" deps;
|
2016-04-14 17:53:13 +01:00
|
|
|
binpath = makeBinPath deps;
|
|
|
|
|
2015-11-08 17:55:47 +00:00
|
|
|
installPhase = ''
|
2021-12-23 16:43:01 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
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
|
|
|
|
|
2022-01-17 23:15:18 +00:00
|
|
|
|
|
|
|
substituteInPlace $out/share/google/$appname/google-$appname \
|
|
|
|
--replace 'CHROME_WRAPPER' 'WRAPPER'
|
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 \
|
2020-04-16 12:31:59 +01:00
|
|
|
--replace $out/share/google/$appname/google-$appname $exe
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2020-08-21 19:39:05 +01: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_}"
|
2020-08-21 19:39:05 +01:00
|
|
|
if [ $dist = "stable" ]; then
|
|
|
|
icon_size="''${num_and_suffix%.*}"
|
|
|
|
else
|
|
|
|
icon_size="''${num_and_suffix%_*}"
|
|
|
|
fi
|
2015-11-08 17:55:47 +00:00
|
|
|
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
|
|
|
|
|
2018-03-06 13:00:14 +00:00
|
|
|
makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$rpath" \
|
|
|
|
--prefix PATH : "$binpath" \
|
2022-01-31 18:16:47 +00:00
|
|
|
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
|
2022-01-17 23:15:18 +00:00
|
|
|
--set CHROME_WRAPPER "google-chrome-$dist" \
|
2021-11-27 00:54:14 +00:00
|
|
|
--add-flags ${escapeShellArg commandLineArgs} \
|
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
|
2015-11-08 17:55:47 +00:00
|
|
|
|
2021-08-20 12:48:07 +01:00
|
|
|
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,${crashpadHandlerBinary},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
|
2021-12-23 16:43:01 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2015-11-08 17:55:47 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A freeware web browser developed by Google";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.google.com/chrome/browser/";
|
2015-11-08 17:55:47 +00:00
|
|
|
license = licenses.unfree;
|
2020-11-27 15:44:59 +00:00
|
|
|
maintainers = with maintainers; [ primeos ];
|
2020-10-29 12:40:12 +00:00
|
|
|
# Note from primeos: By updating Chromium I also update Google Chrome and
|
|
|
|
# will try to merge PRs and respond to issues but I'm not actually using
|
2020-11-27 15:44:59 +00:00
|
|
|
# Google Chrome.
|
2017-12-06 06:21:53 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2021-04-27 18:21:53 +01:00
|
|
|
mainProgram =
|
|
|
|
if (channel == "dev") then "google-chrome-unstable"
|
|
|
|
else "google-chrome-${channel}";
|
2015-11-08 17:55:47 +00:00
|
|
|
};
|
|
|
|
}
|