2019-11-06 19:37:25 +00:00
|
|
|
{ newScope, config, stdenv, fetchurl, makeWrapper
|
2020-09-06 22:20:30 +01:00
|
|
|
, llvmPackages_10, llvmPackages_11, ed, gnugrep, coreutils, xdg_utils
|
2020-04-03 18:17:57 +01:00
|
|
|
, glib, gtk3, gnome3, gsettings-desktop-schemas, gn, fetchgit
|
2019-02-18 08:17:05 +00:00
|
|
|
, libva ? null
|
2020-06-06 17:08:39 +01:00
|
|
|
, pipewire_0_2
|
2020-07-08 20:55:09 +01:00
|
|
|
, gcc, nspr, nss, runCommand
|
2019-08-11 00:09:55 +01:00
|
|
|
, lib
|
2012-12-03 16:55:09 +00:00
|
|
|
|
2012-12-03 17:23:49 +00:00
|
|
|
# package customization
|
2020-04-13 14:26:09 +01:00
|
|
|
# Note: enable* flags should not require full rebuilds (i.e. only affect the wrapper)
|
2012-12-03 16:55:09 +00:00
|
|
|
, channel ? "stable"
|
2016-09-13 18:42:55 +01:00
|
|
|
, gnomeSupport ? false, gnome ? null
|
2014-03-19 11:21:10 +00:00
|
|
|
, gnomeKeyringSupport ? false
|
2012-12-03 17:23:49 +00:00
|
|
|
, proprietaryCodecs ? true
|
2014-03-19 10:32:39 +00:00
|
|
|
, enablePepperFlash ? false
|
2014-09-30 05:00:47 +01:00
|
|
|
, enableWideVine ? false
|
2020-04-13 14:26:09 +01:00
|
|
|
, useVaapi ? false # Deprecated, use enableVaapi instead!
|
|
|
|
, enableVaapi ? false # Disabled by default due to unofficial support and issues on radeon
|
2020-02-04 21:08:31 +00:00
|
|
|
, useOzone ? false
|
2014-12-07 13:52:36 +00:00
|
|
|
, cupsSupport ? true
|
2019-02-03 15:31:25 +00:00
|
|
|
, pulseSupport ? config.pulseaudio or stdenv.isLinux
|
2017-01-05 16:46:37 +00:00
|
|
|
, commandLineArgs ? ""
|
chromium: Minimal build (no install) from source.
This only gets chromium to build so far, installation is missing by upstream, so
we need to manually copy the corresponding files. And I guess with nix, we also
need to patch a few paths on installation.
Another issue is that at the moment, a lot of dependencies are used from the
source tree, rather than from the system.
Also, it would be nice to build using LLVM, as it really speeds up compilation a
*LOT* and also has the side effect of resulting in smaller binaries.
Working unit tests would be nice, too. Unfortunately they're quite heavyweight
and take hours to run, so I guess "someday" would be the most appropriate time
to integrate.
Further todo's:
- Allow to disable GConf, GIO and CUPS.
- Option to disable the sandbox (for whatever reason the user might have).
- Integrate gold binutils.
- Pulseaudio support.
- Clearly separate Linux specific stuff.
2012-06-12 09:19:22 +01:00
|
|
|
}:
|
2009-10-30 08:45:58 +00:00
|
|
|
|
chromium: Minimal build (no install) from source.
This only gets chromium to build so far, installation is missing by upstream, so
we need to manually copy the corresponding files. And I guess with nix, we also
need to patch a few paths on installation.
Another issue is that at the moment, a lot of dependencies are used from the
source tree, rather than from the system.
Also, it would be nice to build using LLVM, as it really speeds up compilation a
*LOT* and also has the side effect of resulting in smaller binaries.
Working unit tests would be nice, too. Unfortunately they're quite heavyweight
and take hours to run, so I guess "someday" would be the most appropriate time
to integrate.
Further todo's:
- Allow to disable GConf, GIO and CUPS.
- Option to disable the sandbox (for whatever reason the user might have).
- Integrate gold binutils.
- Pulseaudio support.
- Clearly separate Linux specific stuff.
2012-06-12 09:19:22 +01:00
|
|
|
let
|
2020-05-19 22:17:34 +01:00
|
|
|
llvmPackages = llvmPackages_10;
|
2020-02-26 18:14:44 +00:00
|
|
|
stdenv = llvmPackages.stdenv;
|
2019-02-03 15:31:25 +00:00
|
|
|
|
2014-03-19 11:21:10 +00:00
|
|
|
callPackage = newScope chromium;
|
2014-03-19 10:32:39 +00:00
|
|
|
|
2020-08-25 22:03:35 +01:00
|
|
|
chromium = rec {
|
2018-10-28 16:07:19 +00:00
|
|
|
inherit stdenv llvmPackages;
|
2018-10-24 22:25:36 +01:00
|
|
|
|
2019-11-06 19:37:25 +00:00
|
|
|
upstream-info = (lib.importJSON ./upstream-info.json).${channel};
|
2014-03-19 11:51:39 +00:00
|
|
|
|
2020-04-03 18:17:57 +01:00
|
|
|
mkChromiumDerivation = callPackage ./common.nix ({
|
2019-11-06 19:37:25 +00:00
|
|
|
inherit channel gnome gnomeSupport gnomeKeyringSupport proprietaryCodecs
|
|
|
|
cupsSupport pulseSupport useOzone;
|
2020-04-03 18:17:57 +01:00
|
|
|
# TODO: Remove after we can update gn for the stable channel (backward incompatible changes):
|
2020-06-06 17:43:04 +01:00
|
|
|
gnChromium = gn.overrideAttrs (oldAttrs: {
|
|
|
|
version = "2020-05-19";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://gn.googlesource.com/gn";
|
|
|
|
rev = "d0a6f072070988e7b038496c4e7d6c562b649732";
|
|
|
|
sha256 = "0197msabskgfbxvhzq73gc3wlr3n9cr4bzrhy5z5irbvy05lxk17";
|
|
|
|
};
|
|
|
|
});
|
2020-08-25 22:03:35 +01:00
|
|
|
} // lib.optionalAttrs (lib.versionAtLeast upstream-info.version "86") {
|
2020-08-25 22:28:00 +01:00
|
|
|
llvmPackages = llvmPackages_11;
|
2020-07-23 21:43:09 +01:00
|
|
|
gnChromium = gn.overrideAttrs (oldAttrs: {
|
|
|
|
version = "2020-07-20";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://gn.googlesource.com/gn";
|
|
|
|
rev = "3028c6a426a4aaf6da91c4ebafe716ae370225fe";
|
|
|
|
sha256 = "0h3wf4152zdvrbb0jbj49q6814lfl3rcy5mj8b2pl9s0ahvkbc6q";
|
|
|
|
};
|
|
|
|
});
|
2020-09-10 11:04:49 +01:00
|
|
|
} // lib.optionalAttrs (lib.versionAtLeast upstream-info.version "87") {
|
|
|
|
llvmPackages = llvmPackages_11;
|
|
|
|
useOzone = true; # YAY: https://chromium-review.googlesource.com/c/chromium/src/+/2382834 \o/
|
|
|
|
gnChromium = gn.overrideAttrs (oldAttrs: {
|
|
|
|
version = "2020-08-17";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://gn.googlesource.com/gn";
|
|
|
|
rev = "6f13aaac55a977e1948910942675c69f2b4f7a94";
|
|
|
|
sha256 = "01hpma1sllpdx09mvr4d6073sg6zmk6iv44kd3r28khymcj4s251";
|
|
|
|
};
|
|
|
|
});
|
2020-04-03 18:17:57 +01:00
|
|
|
});
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2019-09-05 22:27:04 +01:00
|
|
|
browser = callPackage ./browser.nix { inherit channel enableWideVine; };
|
2014-03-22 16:05:14 +00:00
|
|
|
|
2014-03-19 11:57:49 +00:00
|
|
|
plugins = callPackage ./plugins.nix {
|
2019-04-23 02:47:19 +01:00
|
|
|
inherit enablePepperFlash;
|
2014-03-19 10:32:39 +00:00
|
|
|
};
|
2018-10-28 16:07:19 +00:00
|
|
|
};
|
2014-03-19 10:32:39 +00:00
|
|
|
|
2019-11-06 19:37:25 +00:00
|
|
|
pkgSuffix = if channel == "dev" then "unstable" else channel;
|
|
|
|
pkgName = "google-chrome-${pkgSuffix}";
|
|
|
|
chromeSrc = fetchurl {
|
2020-09-06 13:54:42 +01:00
|
|
|
urls = map (repo: "${repo}/${pkgName}/${pkgName}_${version}-1_amd64.deb") [
|
2019-11-06 19:37:25 +00:00
|
|
|
"https://dl.google.com/linux/chrome/deb/pool/main/g"
|
|
|
|
"http://95.31.35.30/chrome/pool/main/g"
|
|
|
|
"http://mirror.pcbeta.com/google/chrome/deb/pool/main/g"
|
|
|
|
"http://repo.fdzh.org/chrome/deb/pool/main/g"
|
|
|
|
];
|
|
|
|
sha256 = chromium.upstream-info.sha256bin64;
|
|
|
|
};
|
|
|
|
|
2019-08-11 00:09:55 +01:00
|
|
|
mkrpath = p: "${lib.makeSearchPathOutput "lib" "lib64" p}:${lib.makeLibraryPath p}";
|
2019-11-06 19:37:25 +00:00
|
|
|
widevineCdm = stdenv.mkDerivation {
|
2019-12-15 04:16:24 +00:00
|
|
|
name = "chrome-widevine-cdm";
|
2019-08-11 00:09:55 +01:00
|
|
|
|
2019-11-06 19:37:25 +00:00
|
|
|
src = chromeSrc;
|
2019-08-11 00:09:55 +01:00
|
|
|
|
|
|
|
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
|
|
|
|
|
|
|
|
unpackCmd = let
|
2019-12-15 04:16:24 +00:00
|
|
|
widevineCdmPath =
|
2019-11-06 19:37:25 +00:00
|
|
|
if channel == "stable" then
|
2019-12-15 04:16:24 +00:00
|
|
|
"./opt/google/chrome/WidevineCdm"
|
2019-11-06 19:37:25 +00:00
|
|
|
else if channel == "beta" then
|
2019-12-15 04:16:24 +00:00
|
|
|
"./opt/google/chrome-beta/WidevineCdm"
|
2019-11-06 19:37:25 +00:00
|
|
|
else if channel == "dev" then
|
2019-12-15 04:16:24 +00:00
|
|
|
"./opt/google/chrome-unstable/WidevineCdm"
|
2019-09-18 22:30:15 +01:00
|
|
|
else
|
|
|
|
throw "Unknown chromium channel.";
|
2019-08-11 00:09:55 +01:00
|
|
|
in ''
|
2019-12-15 04:16:24 +00:00
|
|
|
# Extract just WidevineCdm from upstream's .deb file
|
|
|
|
ar p "$src" data.tar.xz | tar xJ "${widevineCdmPath}"
|
|
|
|
|
|
|
|
# Move things around so that we don't have to reference a particular
|
|
|
|
# chrome-* directory later.
|
|
|
|
mv "${widevineCdmPath}" ./
|
|
|
|
|
|
|
|
# unpackCmd wants a single output directory; let it take WidevineCdm/
|
|
|
|
rm -rf opt
|
2019-08-11 00:09:55 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
! find -iname '*.so' -exec ldd {} + | grep 'not found'
|
|
|
|
'';
|
|
|
|
|
|
|
|
PATCH_RPATH = mkrpath [ gcc.cc glib nspr nss ];
|
|
|
|
|
|
|
|
patchPhase = ''
|
2019-12-15 04:16:24 +00:00
|
|
|
patchelf --set-rpath "$PATCH_RPATH" _platform_specific/linux_x64/libwidevinecdm.so
|
2019-08-11 00:09:55 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-12-15 04:16:24 +00:00
|
|
|
mkdir -p $out/WidevineCdm
|
|
|
|
cp -a * $out/WidevineCdm/
|
2019-08-11 00:09:55 +01:00
|
|
|
'';
|
|
|
|
|
2019-09-18 22:30:15 +01:00
|
|
|
meta = {
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
license = lib.licenses.unfree;
|
|
|
|
};
|
2019-08-11 00:09:55 +01:00
|
|
|
};
|
|
|
|
|
2014-11-25 09:08:28 +00:00
|
|
|
suffix = if channel != "stable" then "-" + channel else "";
|
|
|
|
|
2016-08-06 09:13:20 +01:00
|
|
|
sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName;
|
|
|
|
|
2017-06-16 06:49:50 +01:00
|
|
|
version = chromium.browser.version;
|
|
|
|
|
2019-09-18 22:30:15 +01:00
|
|
|
# We want users to be able to enableWideVine without rebuilding all of
|
|
|
|
# chromium, so we have a separate derivation here that copies chromium
|
2019-12-15 04:16:24 +00:00
|
|
|
# and adds the unfree WidevineCdm.
|
2019-08-11 00:09:55 +01:00
|
|
|
chromiumWV = let browser = chromium.browser; in if enableWideVine then
|
|
|
|
runCommand (browser.name + "-wv") { version = browser.version; }
|
|
|
|
''
|
|
|
|
mkdir -p $out
|
2019-09-18 22:30:15 +01:00
|
|
|
cp -a ${browser}/* $out/
|
|
|
|
chmod u+w $out/libexec/chromium
|
2019-12-15 04:16:24 +00:00
|
|
|
cp -a ${widevineCdm}/WidevineCdm $out/libexec/chromium/
|
2019-08-11 00:09:55 +01:00
|
|
|
''
|
|
|
|
else browser;
|
2020-04-13 14:26:09 +01:00
|
|
|
|
|
|
|
optionalVaapiFlags = if useVaapi # TODO: Remove after 20.09:
|
|
|
|
then throw ''
|
|
|
|
Chromium's useVaapi was replaced by enableVaapi and you don't need to pass
|
|
|
|
"--ignore-gpu-blacklist" anymore (also no rebuilds are required anymore).
|
|
|
|
'' else lib.optionalString
|
|
|
|
(!enableVaapi)
|
|
|
|
"--add-flags --disable-accelerated-video-decode --add-flags --disable-accelerated-video-encode";
|
2014-03-22 16:05:14 +00:00
|
|
|
in stdenv.mkDerivation {
|
2017-06-16 06:49:50 +01:00
|
|
|
name = "chromium${suffix}-${version}";
|
|
|
|
inherit version;
|
2014-03-22 16:05:14 +00:00
|
|
|
|
2017-06-16 06:49:50 +01:00
|
|
|
buildInputs = [
|
|
|
|
makeWrapper ed
|
|
|
|
|
|
|
|
# needed for GSETTINGS_SCHEMAS_PATH
|
2018-02-25 02:23:58 +00:00
|
|
|
gsettings-desktop-schemas glib gtk3
|
2017-06-16 06:49:50 +01:00
|
|
|
|
|
|
|
# needed for XDG_ICON_DIRS
|
2019-02-13 21:47:50 +00:00
|
|
|
gnome3.adwaita-icon-theme
|
2017-06-16 06:49:50 +01:00
|
|
|
];
|
2014-03-22 16:05:14 +00:00
|
|
|
|
2016-08-06 09:13:20 +01:00
|
|
|
outputs = ["out" "sandbox"];
|
|
|
|
|
2014-03-22 16:05:14 +00:00
|
|
|
buildCommand = let
|
2019-08-11 00:09:55 +01:00
|
|
|
browserBinary = "${chromiumWV}/libexec/chromium/chromium";
|
2016-02-02 04:04:41 +00:00
|
|
|
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
|
2020-06-06 17:08:39 +01:00
|
|
|
libPath = stdenv.lib.makeLibraryPath [ libva pipewire_0_2 ];
|
2019-02-18 08:17:05 +00:00
|
|
|
|
2014-11-25 12:39:16 +00:00
|
|
|
in with stdenv.lib; ''
|
2016-08-27 16:38:25 +01:00
|
|
|
mkdir -p "$out/bin"
|
2012-06-15 09:19:26 +01:00
|
|
|
|
2016-08-19 19:18:14 +01:00
|
|
|
eval makeWrapper "${browserBinary}" "$out/bin/chromium" \
|
2018-03-06 13:00:14 +00:00
|
|
|
--add-flags ${escapeShellArg (escapeShellArg commandLineArgs)} \
|
2020-04-13 14:26:09 +01:00
|
|
|
${optionalVaapiFlags} \
|
2016-02-02 04:04:41 +00:00
|
|
|
${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled}
|
2012-06-15 09:19:26 +01:00
|
|
|
|
2016-08-19 19:18:14 +01:00
|
|
|
ed -v -s "$out/bin/chromium" << EOF
|
|
|
|
2i
|
|
|
|
|
2017-01-29 10:11:01 +00:00
|
|
|
if [ -x "/run/wrappers/bin/${sandboxExecutableName}" ]
|
2016-08-19 19:18:14 +01:00
|
|
|
then
|
2017-01-29 10:11:01 +00:00
|
|
|
export CHROME_DEVEL_SANDBOX="/run/wrappers/bin/${sandboxExecutableName}"
|
2016-08-19 19:18:14 +01:00
|
|
|
else
|
|
|
|
export CHROME_DEVEL_SANDBOX="$sandbox/bin/${sandboxExecutableName}"
|
|
|
|
fi
|
|
|
|
|
2019-10-30 22:39:17 +00:00
|
|
|
'' + lib.optionalString (libPath != "") ''
|
|
|
|
# To avoid loading .so files from cwd, LD_LIBRARY_PATH here must not
|
|
|
|
# contain an empty section before or after a colon.
|
|
|
|
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH\''${LD_LIBRARY_PATH:+:}${libPath}"
|
|
|
|
'' + ''
|
2019-02-18 08:17:05 +00:00
|
|
|
|
2016-08-19 19:18:14 +01:00
|
|
|
# libredirect causes chromium to deadlock on startup
|
2020-08-03 16:58:41 +01:00
|
|
|
export LD_PRELOAD="\$(echo -n "\$LD_PRELOAD" | ${coreutils}/bin/tr ':' '\n' | ${gnugrep}/bin/grep -v /lib/libredirect\\\\.so$ | ${coreutils}/bin/tr '\n' ':')"
|
2016-08-19 19:18:14 +01:00
|
|
|
|
2017-06-16 06:49:50 +01:00
|
|
|
export XDG_DATA_DIRS=$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH\''${XDG_DATA_DIRS:+:}\$XDG_DATA_DIRS
|
|
|
|
|
2020-09-06 22:20:30 +01:00
|
|
|
# Mainly for xdg-open but also other xdg-* tools:
|
|
|
|
export PATH="${xdg_utils}/bin\''${PATH:+:}\$PATH"
|
|
|
|
|
2016-08-19 19:18:14 +01:00
|
|
|
.
|
|
|
|
w
|
|
|
|
EOF
|
2016-08-06 09:13:20 +01:00
|
|
|
|
2016-08-06 10:09:40 +01:00
|
|
|
ln -sv "${chromium.browser.sandbox}" "$sandbox"
|
2016-08-06 09:13:20 +01:00
|
|
|
|
2014-09-19 06:51:11 +01:00
|
|
|
ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
|
2016-08-27 16:38:25 +01:00
|
|
|
|
2019-05-28 01:32:18 +01:00
|
|
|
mkdir -p "$out/share"
|
2018-01-21 23:33:47 +00:00
|
|
|
for f in '${chromium.browser}'/share/*; do # hello emacs */
|
2016-08-27 16:38:25 +01:00
|
|
|
ln -s -t "$out/share/" "$f"
|
|
|
|
done
|
2014-03-22 16:05:14 +00:00
|
|
|
'';
|
2014-03-23 18:48:53 +00:00
|
|
|
|
2018-01-21 23:33:47 +00:00
|
|
|
inherit (chromium.browser) packageName;
|
2019-04-23 02:47:19 +01:00
|
|
|
meta = chromium.browser.meta;
|
2014-04-01 06:36:26 +01:00
|
|
|
passthru = {
|
2016-08-06 14:40:56 +01:00
|
|
|
inherit (chromium) upstream-info browser;
|
2014-04-01 06:36:26 +01:00
|
|
|
mkDerivation = chromium.mkChromiumDerivation;
|
2019-11-06 19:37:25 +00:00
|
|
|
inherit chromeSrc sandboxExecutableName;
|
|
|
|
updateScript = ./update.py;
|
2014-04-01 06:36:26 +01:00
|
|
|
};
|
2014-03-22 16:05:14 +00:00
|
|
|
}
|