Rework to avoid a full rebuild for widevine.

This commit is contained in:
Julien Langlois 2019-08-10 19:09:55 -04:00
parent 545d58a1ef
commit aeeb67bfcb
No known key found for this signature in database
GPG Key ID: BB220B0A40F7F862
3 changed files with 59 additions and 50 deletions

View File

@ -1,47 +1,8 @@
{ stdenv, mkChromiumDerivation, channel, upstream-info, gcc, glib, nspr, nss, patchelfUnstable, enableWideVine }: { stdenv, mkChromiumDerivation, channel }:
with stdenv.lib; with stdenv.lib;
let mkChromiumDerivation (base: rec {
mkrpath = p: "${makeSearchPathOutput "lib" "lib64" p}:${makeLibraryPath p}";
widevine = stdenv.mkDerivation {
name = "chromium-binary-plugin-widevine";
src = upstream-info.binary;
nativeBuildInputs = [ patchelfUnstable ];
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
unpackCmd = let
chan = if upstream-info.channel == "dev" then "chrome-unstable"
else if upstream-info.channel == "stable" then "chrome"
else "chrome-${upstream-info.channel}";
in ''
mkdir -p plugins
ar p "$src" data.tar.xz | tar xJ -C plugins --strip-components=4 \
./opt/google/${chan}/libwidevinecdm.so
'';
doCheck = true;
checkPhase = ''
! find -iname '*.so' -exec ldd {} + | grep 'not found'
'';
PATCH_RPATH = mkrpath [ gcc.cc glib nspr nss ];
patchPhase = ''
patchelf --set-rpath "$PATCH_RPATH" libwidevinecdm.so
'';
installPhase = ''
install -vD libwidevinecdm.so \
"$out/lib/libwidevinecdm.so"
'';
meta.platforms = platforms.x86_64;
};
in mkChromiumDerivation (base: rec {
name = "chromium-browser"; name = "chromium-browser";
packageName = "chromium"; packageName = "chromium";
buildTargets = [ "mksnapshot" "chrome_sandbox" "chrome" ]; buildTargets = [ "mksnapshot" "chrome_sandbox" "chrome" ];
@ -91,8 +52,6 @@ in mkChromiumDerivation (base: rec {
-e '/\[Desktop Entry\]/a\' \ -e '/\[Desktop Entry\]/a\' \
-e 'StartupWMClass=chromium-browser' \ -e 'StartupWMClass=chromium-browser' \
$out/share/applications/chromium-browser.desktop $out/share/applications/chromium-browser.desktop
${optionalString enableWideVine "ln -s ${widevine}/lib/libwidevinecdm.so \"$libExecPath/libwidevinecdm.so\""}
''; '';
passthru = { inherit sandboxExecutableName; }; passthru = { inherit sandboxExecutableName; };

View File

@ -24,7 +24,6 @@
# package customization # package customization
, enableNaCl ? false , enableNaCl ? false
, enableWideVine ? false
, useVaapi ? false , useVaapi ? false
, gnomeSupport ? false, gnome ? null , gnomeSupport ? false, gnome ? null
, gnomeKeyringSupport ? false, libgnome-keyring3 ? null , gnomeKeyringSupport ? false, libgnome-keyring3 ? null
@ -133,11 +132,12 @@ let
++ optional pulseSupport libpulseaudio ++ optional pulseSupport libpulseaudio
++ optional (versionAtLeast version "72") jdk.jre; ++ optional (versionAtLeast version "72") jdk.jre;
patches = optional enableWideVine ./patches/widevine.patch ++ [ patches = [
./patches/nix_plugin_paths_68.patch ./patches/nix_plugin_paths_68.patch
./patches/remove-webp-include-69.patch ./patches/remove-webp-include-69.patch
./patches/jumbo-sorted.patch ./patches/jumbo-sorted.patch
./patches/no-build-timestamps.patch ./patches/no-build-timestamps.patch
./patches/widevine.patch
# Unfortunately, chromium regularly breaks on major updates and # Unfortunately, chromium regularly breaks on major updates and
# then needs various patches backported in order to be compiled with GCC. # then needs various patches backported in order to be compiled with GCC.
@ -245,7 +245,7 @@ let
use_gnome_keyring = gnomeKeyringSupport; use_gnome_keyring = gnomeKeyringSupport;
use_gio = gnomeSupport; use_gio = gnomeSupport;
enable_nacl = enableNaCl; enable_nacl = enableNaCl;
enable_widevine = enableWideVine; enable_widevine = true;
use_cups = cupsSupport; use_cups = cupsSupport;
treat_warnings_as_errors = false; treat_warnings_as_errors = false;

View File

@ -2,6 +2,8 @@
, makeWrapper, ed , makeWrapper, ed
, glib, gtk3, gnome3, gsettings-desktop-schemas , glib, gtk3, gnome3, gsettings-desktop-schemas
, libva ? null , libva ? null
, gcc, nspr, nss, patchelfUnstable, runCommand
, lib
# package customization # package customization
, channel ? "stable" , channel ? "stable"
@ -34,23 +36,71 @@ in let
mkChromiumDerivation = callPackage ./common.nix { mkChromiumDerivation = callPackage ./common.nix {
inherit enableNaCl gnomeSupport gnome inherit enableNaCl gnomeSupport gnome
gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport
useVaapi useVaapi;
enableWideVine;
}; };
browser = callPackage ./browser.nix { inherit channel enableWideVine; }; browser = callPackage ./browser.nix { inherit channel; };
plugins = callPackage ./plugins.nix { plugins = callPackage ./plugins.nix {
inherit enablePepperFlash; inherit enablePepperFlash;
}; };
}; };
mkrpath = p: "${lib.makeSearchPathOutput "lib" "lib64" p}:${lib.makeLibraryPath p}";
widevine = let upstream-info = chromium.upstream-info; in stdenv.mkDerivation {
name = "chromium-binary-plugin-widevine";
src = upstream-info.binary;
nativeBuildInputs = [ patchelfUnstable ];
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
unpackCmd = let
chan = if upstream-info.channel == "dev" then "chrome-unstable"
else if upstream-info.channel == "stable" then "chrome"
else "chrome-${upstream-info.channel}";
in ''
mkdir -p plugins
ar p "$src" data.tar.xz | tar xJ -C plugins --strip-components=4 \
./opt/google/${chan}/libwidevinecdm.so
'';
doCheck = true;
checkPhase = ''
! find -iname '*.so' -exec ldd {} + | grep 'not found'
'';
PATCH_RPATH = mkrpath [ gcc.cc glib nspr nss ];
patchPhase = ''
patchelf --set-rpath "$PATCH_RPATH" libwidevinecdm.so
'';
installPhase = ''
install -vD libwidevinecdm.so \
"$out/lib/libwidevinecdm.so"
'';
meta.platforms = lib.platforms.x86_64;
};
suffix = if channel != "stable" then "-" + channel else ""; suffix = if channel != "stable" then "-" + channel else "";
sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName; sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName;
version = chromium.browser.version; version = chromium.browser.version;
chromiumWV = let browser = chromium.browser; in if enableWideVine then
runCommand (browser.name + "-wv") { version = browser.version; }
''
mkdir -p $out
cp -R ${browser}/* $out/
chmod u+w $out/libexec/chromium*
cp ${widevine}/lib/libwidevinecdm.so $out/libexec/chromium/
# patchelf?
''
else browser;
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "chromium${suffix}-${version}"; name = "chromium${suffix}-${version}";
inherit version; inherit version;
@ -68,7 +118,7 @@ in stdenv.mkDerivation {
outputs = ["out" "sandbox"]; outputs = ["out" "sandbox"];
buildCommand = let buildCommand = let
browserBinary = "${chromium.browser}/libexec/chromium/chromium"; browserBinary = "${chromiumWV}/libexec/chromium/chromium";
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")"; getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
libPath = stdenv.lib.makeLibraryPath ([] libPath = stdenv.lib.makeLibraryPath ([]
++ stdenv.lib.optional useVaapi libva ++ stdenv.lib.optional useVaapi libva