about summary refs log tree commit diff
diff options
context:
space:
mode:
authoremilylange <git@emilylange.de>2024-05-13 01:21:58 +0200
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2024-05-13 00:29:40 +0000
commitcc7be6285aceefa9b4ed8af7f46e0e2978273258 (patch)
treeac0480eeacc07aab87140be6ccf78ea88c261788
parent6eccabe980dcb2048aab7f97f862fb6d79b98abe (diff)
chromium: remove internal widevine drv in favor of `widevine-cdm`
This gets rid of a lot of redundant logic that is already present in the
`widevine-cdm` package :)

The resulting directory structure is the same and works just as well.

(cherry picked from commit 0333f6c792947f7720b51c2b2b1daca1f7f8cf9c)
-rw-r--r--pkgs/applications/networking/browsers/chromium/default.nix77
-rwxr-xr-xpkgs/applications/networking/browsers/chromium/update.py5
-rw-r--r--pkgs/applications/networking/browsers/chromium/upstream-info.nix2
3 files changed, 3 insertions, 81 deletions
diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix
index 0dd1248e6ebc5..4dc2ce17ca900 100644
--- a/pkgs/applications/networking/browsers/chromium/default.nix
+++ b/pkgs/applications/networking/browsers/chromium/default.nix
@@ -5,6 +5,7 @@
 , libva, pipewire, wayland
 , gcc, nspr, nss, runCommand
 , lib, libkrb5
+, widevine-cdm
 , electron-source # for warnObsoleteVersionConditional
 
 # package customization
@@ -84,78 +85,6 @@ let
     ungoogled-chromium = pkgsBuildBuild.callPackage ./ungoogled.nix {};
   };
 
-  pkgSuffix = if channel == "dev" then "unstable" else
-    (if channel == "ungoogled-chromium" then "stable" else channel);
-  pkgName = "google-chrome-${pkgSuffix}";
-  chromeSrc =
-    let
-      # Use the latest stable Chrome version if necessary:
-      version = if chromium.upstream-info.hash_deb_amd64 != null
-        then chromium.upstream-info.version
-        else (import ./upstream-info.nix).stable.version;
-      hash = if chromium.upstream-info.hash_deb_amd64 != null
-        then chromium.upstream-info.hash_deb_amd64
-        else (import ./upstream-info.nix).stable.hash_deb_amd64;
-    in fetchurl {
-      urls = map (repo: "${repo}/${pkgName}/${pkgName}_${version}-1_amd64.deb") [
-        "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"
-      ];
-      inherit hash;
-  };
-
-  mkrpath = p: "${lib.makeSearchPathOutput "lib" "lib64" p}:${lib.makeLibraryPath p}";
-  widevineCdm = stdenv.mkDerivation {
-    name = "chrome-widevine-cdm";
-
-    src = chromeSrc;
-
-    unpackCmd = let
-      widevineCdmPath =
-        if (channel == "stable" || channel == "ungoogled-chromium") then
-          "./opt/google/chrome/WidevineCdm"
-        else if channel == "beta" then
-          "./opt/google/chrome-beta/WidevineCdm"
-        else if channel == "dev" then
-          "./opt/google/chrome-unstable/WidevineCdm"
-        else
-          throw "Unknown chromium channel.";
-    in ''
-      # 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
-    '';
-
-    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" _platform_specific/linux_x64/libwidevinecdm.so
-    '';
-
-    installPhase = ''
-      mkdir -p $out/WidevineCdm
-      cp -a * $out/WidevineCdm/
-    '';
-
-    meta = {
-      platforms = [ "x86_64-linux" ];
-      license = lib.licenses.unfree;
-    };
-  };
-
   suffix = lib.optionalString (channel != "stable" && channel != "ungoogled-chromium") ("-" + channel);
 
   sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName;
@@ -169,7 +98,7 @@ let
         mkdir -p $out
         cp -a ${browser}/* $out/
         chmod u+w $out/libexec/chromium
-        cp -a ${widevineCdm}/WidevineCdm $out/libexec/chromium/
+        cp -a ${widevine-cdm}/share/google/chrome/WidevineCdm $out/libexec/chromium/
       ''
     else browser;
 
@@ -254,7 +183,7 @@ in stdenv.mkDerivation {
   passthru = {
     inherit (chromium) upstream-info browser;
     mkDerivation = chromium.mkChromiumDerivation;
-    inherit chromeSrc sandboxExecutableName;
+    inherit sandboxExecutableName;
   };
 }
 # the following is a complicated and long-winded variant of
diff --git a/pkgs/applications/networking/browsers/chromium/update.py b/pkgs/applications/networking/browsers/chromium/update.py
index c1d893e0cff91..3107686fa2ec3 100755
--- a/pkgs/applications/networking/browsers/chromium/update.py
+++ b/pkgs/applications/networking/browsers/chromium/update.py
@@ -20,7 +20,6 @@ from os.path import abspath, dirname
 from urllib.request import urlopen
 
 RELEASES_URL = 'https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/all/versions/all/releases'
-DEB_URL = 'https://dl.google.com/linux/chrome/deb/pool/main/g'
 
 PIN_PATH = dirname(abspath(__file__)) + '/upstream-info.nix'
 UNGOOGLED_FLAGS_PATH = dirname(abspath(__file__)) + '/ungoogled-flags.toml'
@@ -259,10 +258,6 @@ with urlopen(RELEASES_URL) as resp:
                     version
                 )
                 src_hash_cache[version] = channel["hash"]
-
-            channel['hash_deb_amd64'] = nix_prefetch_url(
-                f'{DEB_URL}/google-chrome-{google_chrome_suffix}/' +
-                f'google-chrome-{google_chrome_suffix}_{version}-1_amd64.deb')
         except subprocess.CalledProcessError:
             # This release isn't actually available yet.  Continue to
             # the next one.
diff --git a/pkgs/applications/networking/browsers/chromium/upstream-info.nix b/pkgs/applications/networking/browsers/chromium/upstream-info.nix
index 9e91cd5725df0..d3f4d9c14ca0f 100644
--- a/pkgs/applications/networking/browsers/chromium/upstream-info.nix
+++ b/pkgs/applications/networking/browsers/chromium/upstream-info.nix
@@ -16,7 +16,6 @@
       };
     };
     hash = "sha256-nSI+tkJxOedMtYgtiqW37v0ZjgxxU5o/0sH9bPAchBg=";
-    hash_deb_amd64 = "sha256-RvQdpDmWRcsASh1b8M0Zg+AvZprE5qhi14shfo0WlfE=";
     version = "124.0.6367.201";
   };
   ungoogled-chromium = {
@@ -33,7 +32,6 @@
       };
     };
     hash = "sha256-nSI+tkJxOedMtYgtiqW37v0ZjgxxU5o/0sH9bPAchBg=";
-    hash_deb_amd64 = "sha256-RvQdpDmWRcsASh1b8M0Zg+AvZprE5qhi14shfo0WlfE=";
     version = "124.0.6367.201";
   };
 }