diff --git a/pkgs/applications/networking/browsers/chromium/browser.nix b/pkgs/applications/networking/browsers/chromium/browser.nix index 8bdb33ed5d22..e41c3b777f86 100644 --- a/pkgs/applications/networking/browsers/chromium/browser.nix +++ b/pkgs/applications/networking/browsers/chromium/browser.nix @@ -1,8 +1,47 @@ -{ stdenv, mkChromiumDerivation, channel }: +{ stdenv, mkChromiumDerivation, channel, upstream-info, gcc, glib, nspr, nss, patchelfUnstable, enableWideVine }: with stdenv.lib; -mkChromiumDerivation (base: rec { +let + 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"; packageName = "chromium"; buildTargets = [ "mksnapshot" "chrome_sandbox" "chrome" ]; @@ -18,11 +57,6 @@ mkChromiumDerivation (base: rec { cp -vLR "$buildPath/locales" "$buildPath/resources" "$libExecPath/" cp -v "$buildPath/chrome" "$libExecPath/$packageName" - if [ -e "$buildPath/libwidevinecdmadapter.so" ]; then - cp -v "$buildPath/libwidevinecdmadapter.so" \ - "$libExecPath/libwidevinecdmadapter.so" - fi - mkdir -p "$sandbox/bin" cp -v "$buildPath/chrome_sandbox" "$sandbox/bin/${sandboxExecutableName}" @@ -57,6 +91,8 @@ mkChromiumDerivation (base: rec { -e '/\[Desktop Entry\]/a\' \ -e 'StartupWMClass=chromium-browser' \ $out/share/applications/chromium-browser.desktop + + ${optionalString enableWideVine "ln -s ${widevine}/lib/libwidevinecdm.so \"$libExecPath/libwidevinecdm.so\""} ''; passthru = { inherit sandboxExecutableName; }; diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index 3178e2595fc5..b88772bbd318 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -38,10 +38,10 @@ in let enableWideVine; }; - browser = callPackage ./browser.nix { inherit channel; }; + browser = callPackage ./browser.nix { inherit channel enableWideVine; }; plugins = callPackage ./plugins.nix { - inherit enablePepperFlash enableWideVine; + inherit enablePepperFlash; }; }; @@ -113,13 +113,7 @@ in stdenv.mkDerivation { ''; inherit (chromium.browser) packageName; - meta = chromium.browser.meta // { - broken = if enableWideVine then - builtins.trace "WARNING: WideVine is not functional, please only use for testing" - true - else false; - }; - + meta = chromium.browser.meta; passthru = { inherit (chromium) upstream-info browser; mkDerivation = chromium.mkChromiumDerivation; diff --git a/pkgs/applications/networking/browsers/chromium/patches/widevine.patch b/pkgs/applications/networking/browsers/chromium/patches/widevine.patch index 90a13928e3bd..2de6024141d7 100644 --- a/pkgs/applications/networking/browsers/chromium/patches/widevine.patch +++ b/pkgs/applications/networking/browsers/chromium/patches/widevine.patch @@ -1,16 +1,24 @@ -Minimal WideVine patch from Gentoo: +Description: enable widevine and set its version string to "undefined" +Author: Michael Gilbert +Author: Olivier Tilloy -https://gitweb.gentoo.org/repo/gentoo.git/tree/www-client/chromium/files/chromium-widevine-r1.patch - -BTS: https://bugs.gentoo.org/show_bug.cgi?id=547630 - ---- a/third_party/widevine/cdm/stub/widevine_cdm_version.h -+++ b/third_party/widevine/cdm/stub/widevine_cdm_version.h -@@ -10,6 +10,7 @@ - - #include "third_party/widevine/cdm/widevine_cdm_common.h" - -+#define WIDEVINE_CDM_VERSION_STRING "unknown" - #define WIDEVINE_CDM_AVAILABLE +--- a/third_party/widevine/cdm/widevine_cdm_version.h ++++ b/third_party/widevine/cdm/widevine_cdm_version.h +@@ -11,5 +11,6 @@ + // If the Widevine CDM is available define the following: + // - WIDEVINE_CDM_VERSION_STRING (with the version of the CDM that's available + // as a string, e.g., "1.0.123.456"). ++#define WIDEVINE_CDM_VERSION_STRING "undefined" #endif // WIDEVINE_CDM_VERSION_H_ +--- a/chrome/common/chrome_content_client.cc ++++ b/chrome/common/chrome_content_client.cc +@@ -99,7 +99,7 @@ + // Registers Widevine CDM if Widevine is enabled, the Widevine CDM is + // bundled and not a component. When the Widevine CDM is a component, it is + // registered in widevine_cdm_component_installer.cc. +-#if BUILDFLAG(BUNDLE_WIDEVINE_CDM) && !BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) ++#if !BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) + #define REGISTER_BUNDLED_WIDEVINE_CDM + #include "third_party/widevine/cdm/widevine_cdm_common.h" // nogncheck + // TODO(crbug.com/663554): Needed for WIDEVINE_CDM_VERSION_STRING. Support diff --git a/pkgs/applications/networking/browsers/chromium/plugins.nix b/pkgs/applications/networking/browsers/chromium/plugins.nix index a0ea67133c6f..9cf264151af5 100644 --- a/pkgs/applications/networking/browsers/chromium/plugins.nix +++ b/pkgs/applications/networking/browsers/chromium/plugins.nix @@ -6,7 +6,6 @@ , fetchzip , patchelfUnstable , enablePepperFlash ? false -, enableWideVine ? false , upstream-info }: @@ -44,60 +43,6 @@ let echo ${toString quoted} > "''$${output}/nix-support/wrapper-flags" ''; - 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 \ - ./opt/google/${chan}/libwidevinecdmadapter.so - ''; - - doCheck = true; - checkPhase = '' - ! find -iname '*.so' -exec ldd {} + | grep 'not found' - ''; - - PATCH_RPATH = mkrpath [ gcc.cc glib nspr nss ]; - - patchPhase = '' - chmod +x libwidevinecdm.so libwidevinecdmadapter.so - patchelf --set-rpath "$PATCH_RPATH" libwidevinecdm.so - patchelf --set-rpath "$out/lib:$PATCH_RPATH" libwidevinecdmadapter.so - ''; - - installPhase = let - wvName = "Widevine Content Decryption Module"; - wvDescription = "Playback of encrypted HTML audio/video content"; - wvMimeTypes = "application/x-ppapi-widevine-cdm"; - wvModule = "@out@/lib/libwidevinecdmadapter.so"; - wvInfo = "#${wvName}#${wvDescription};${wvMimeTypes}"; - in '' - install -vD libwidevinecdm.so \ - "$out/lib/libwidevinecdm.so" - install -vD libwidevinecdmadapter.so \ - "$out/lib/libwidevinecdmadapter.so" - - ${mkPluginInfo { - flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ]; - envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "@out@/lib"; - }} - ''; - - meta.platforms = platforms.x86_64; - }; - flash = stdenv.mkDerivation rec { pname = "flashplayer-ppapi"; version = "32.0.0.238"; @@ -140,6 +85,5 @@ let }; in { - enabled = optional enableWideVine widevine - ++ optional enablePepperFlash flash; + enabled = optional enablePepperFlash flash; }