2024-05-15 15:35:15 +00:00
|
|
|
{ lib, stdenv, patchelf, makeWrapper, fetchurl, writeScript
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Linked dynamic libraries.
|
2022-02-20 05:27:41 +00:00
|
|
|
, glib, fontconfig, freetype, pango, cairo, libX11, libXi, atk, nss, nspr
|
2020-04-24 23:36:52 +00:00
|
|
|
, libXcursor, libXext, libXfixes, libXrender, libXScrnSaver, libXcomposite, libxcb
|
2021-06-28 23:13:55 +00:00
|
|
|
, alsa-lib, libXdamage, libXtst, libXrandr, libxshmfence, expat, cups
|
2023-03-04 12:14:45 +00:00
|
|
|
, dbus, gtk3, gtk4, gdk-pixbuf, gcc-unwrapped, at-spi2-atk, at-spi2-core
|
2022-01-19 23:45:15 +00:00
|
|
|
, libkrb5, libdrm, libglvnd, mesa
|
2021-09-26 12:46:18 +00:00
|
|
|
, libxkbcommon, pipewire, wayland # ozone/wayland
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
# Command line programs
|
|
|
|
, coreutils
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# command line arguments which are always set e.g "--disable-gpu"
|
|
|
|
, commandLineArgs ? ""
|
|
|
|
|
|
|
|
# Will crash without.
|
|
|
|
, systemd
|
|
|
|
|
|
|
|
# Loaded at runtime.
|
2021-07-26 12:40:57 +00:00
|
|
|
, libexif, pciutils
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Additional dependencies according to other distros.
|
|
|
|
## Ubuntu
|
2021-02-05 17:12:51 +00:00
|
|
|
, liberation_ttf, curl, util-linux, xdg-utils, wget
|
2020-04-24 23:36:52 +00:00
|
|
|
## Arch Linux.
|
|
|
|
, flac, harfbuzz, icu, libpng, libopus, snappy, speechd
|
|
|
|
## Gentoo
|
|
|
|
, bzip2, libcap
|
|
|
|
|
|
|
|
# Necessary for USB audio devices.
|
2022-04-27 09:35:20 +00:00
|
|
|
, pulseSupport ? true, libpulseaudio
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, gsettings-desktop-schemas
|
2021-05-20 23:08:51 +00:00
|
|
|
, gnome
|
2021-03-15 08:37:03 +00:00
|
|
|
|
|
|
|
# For video acceleration via VA-API (--enable-features=VaapiVideoDecoder)
|
|
|
|
, libvaSupport ? true, libva
|
|
|
|
|
|
|
|
# For Vulkan support (--enable-features=Vulkan)
|
2022-01-23 02:10:13 +00:00
|
|
|
, addOpenGLRunpath
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
opusWithCustomModes = libopus.override {
|
|
|
|
withCustomModes = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
deps = [
|
2022-02-20 05:27:41 +00:00
|
|
|
glib fontconfig freetype pango cairo libX11 libXi atk nss nspr
|
2020-04-24 23:36:52 +00:00
|
|
|
libXcursor libXext libXfixes libXrender libXScrnSaver libXcomposite libxcb
|
2021-06-28 23:13:55 +00:00
|
|
|
alsa-lib libXdamage libXtst libXrandr libxshmfence expat cups
|
2020-04-24 23:36:52 +00:00
|
|
|
dbus gdk-pixbuf gcc-unwrapped.lib
|
|
|
|
systemd
|
2021-07-26 12:40:57 +00:00
|
|
|
libexif pciutils
|
2022-08-21 13:32:41 +00:00
|
|
|
liberation_ttf curl util-linux wget
|
2020-04-24 23:36:52 +00:00
|
|
|
flac harfbuzz icu libpng opusWithCustomModes snappy speechd
|
|
|
|
bzip2 libcap at-spi2-atk at-spi2-core
|
2022-01-19 23:45:15 +00:00
|
|
|
libkrb5 libdrm libglvnd mesa coreutils
|
2021-09-26 12:46:18 +00:00
|
|
|
libxkbcommon pipewire wayland
|
2023-02-02 18:25:31 +00:00
|
|
|
] ++ lib.optional pulseSupport libpulseaudio
|
|
|
|
++ lib.optional libvaSupport libva
|
2023-03-04 12:14:45 +00:00
|
|
|
++ [ gtk3 gtk4 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "google-chrome";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "125.0.6422.141";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${finalAttrs.version}-1_amd64.deb";
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-nIdzl3DkvGy9EsNS8nvPi8yK0gvx9mFaxYSxuYZZzxI=";
|
2024-05-15 15:35:15 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ patchelf makeWrapper ];
|
|
|
|
buildInputs = [
|
|
|
|
# needed for GSETTINGS_SCHEMAS_PATH
|
2020-11-30 08:33:03 +00:00
|
|
|
gsettings-desktop-schemas glib gtk3
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# needed for XDG_ICON_DIRS
|
2021-05-20 23:08:51 +00:00
|
|
|
gnome.adwaita-icon-theme
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
ar x $src
|
|
|
|
tar xf data.tar.xz
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
rpath = lib.makeLibraryPath deps + ":" + lib.makeSearchPathOutput "lib" "lib64" deps;
|
|
|
|
binpath = lib.makeBinPath deps;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2021-12-24 04:21:11 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
appname=chrome
|
|
|
|
dist=stable
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
exe=$out/bin/google-chrome-$dist
|
|
|
|
|
|
|
|
mkdir -p $out/bin $out/share
|
|
|
|
|
|
|
|
cp -a opt/* $out/share
|
|
|
|
cp -a usr/share/* $out/share
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
substituteInPlace $out/share/google/$appname/google-$appname \
|
|
|
|
--replace 'CHROME_WRAPPER' 'WRAPPER'
|
2020-04-24 23:36:52 +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 \
|
|
|
|
--replace /opt $out/share \
|
|
|
|
--replace $out/share/google/$appname/google-$appname $exe
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
for icon_file in $out/share/google/chrome*/product_logo_[0-9]*.png; do
|
2020-04-24 23:36:52 +00:00
|
|
|
num_and_suffix="''${icon_file##*logo_}"
|
2020-09-25 04:45:31 +00:00
|
|
|
if [ $dist = "stable" ]; then
|
|
|
|
icon_size="''${num_and_suffix%.*}"
|
|
|
|
else
|
|
|
|
icon_size="''${num_and_suffix%_*}"
|
|
|
|
fi
|
2020-04-24 23:36:52 +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"
|
|
|
|
mv "$icon_file" "$logo_output_path/google-$appname.png"
|
|
|
|
done
|
|
|
|
|
|
|
|
makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$rpath" \
|
|
|
|
--prefix PATH : "$binpath" \
|
2022-08-21 13:32:41 +00:00
|
|
|
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
|
2022-02-10 20:34:41 +00:00
|
|
|
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
|
|
|
|
--set CHROME_WRAPPER "google-chrome-$dist" \
|
2022-10-06 18:32:54 +00:00
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
|
2023-02-02 18:25:31 +00:00
|
|
|
--add-flags ${lib.escapeShellArg commandLineArgs}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,chrome_crashpad_handler}; do
|
2020-04-24 23:36:52 +00:00
|
|
|
patchelf --set-rpath $rpath $elf
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $elf
|
|
|
|
done
|
2021-12-24 04:21:11 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = writeScript "update-google-chrome.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts
|
2024-06-05 15:53:02 +00:00
|
|
|
set -euo pipefail
|
2024-05-15 15:35:15 +00:00
|
|
|
url="https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions/all/releases"
|
2024-06-05 15:53:02 +00:00
|
|
|
response="$(curl --silent --fail $url)"
|
|
|
|
version="$(jq ".releases[0].version" --raw-output <<< $response)"
|
|
|
|
update-source-version ${finalAttrs.pname} $version --ignore-same-hash
|
2024-05-15 15:35:15 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A freeware web browser developed by Google";
|
|
|
|
homepage = "https://www.google.com/chrome/browser/";
|
2024-05-15 15:35:15 +00:00
|
|
|
license = lib.licenses.unfree;
|
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
|
|
maintainers = with lib.maintainers; [ jnsgruk johnrtitor ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2024-05-15 15:35:15 +00:00
|
|
|
mainProgram = "google-chrome-stable";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
})
|