NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.12k stars 13.41k forks source link

Package request: widevine-cdm arm64 #220828

Open schnusch opened 1 year ago

schnusch commented 1 year ago

Project description

It seems widevine is now available for arm64.

https://github.com/raspberrypi/Raspberry-Pi-OS-64bit/issues/248

Metadata

diamondburned commented 11 months ago

Here's my attempt at making Widevine work with Firefox on Asahi Linux M1: diamondburned/dotfiles/Scripts/nix/machines/lilyhoshii/cfg/firefox. I still can't get Spotify to work despite this, but perhaps I'm missing something.

At the very least, Firefox seems to see that the addon is there:

image

A lot of this code is also based on https://github.com/NixOS/nixpkgs/pull/251085.

This is the furthest that I'm able to get :(

image

liarokapisv commented 6 months ago

@diamondburned Had any progress with this ?

liarokapisv commented 6 months ago

I managed to make widevine work on aarch64 using the same sources and commands as the asahi widevine installer. I think one could avoid downloading the whole chromeos image. I will make a PR when I find more free time. In the meantime:

{ stdenvNoCC
, fetchFromGitHub
, fetchurl
, python3
, squashfsTools
, nspr
}:
let
  widevine-installer = fetchFromGitHub {
    owner = "AsahiLinux";
    repo = "widevine-installer";
    rev = "7a3928fe1342fb07d96f61c2b094e3287588958b";
    sha256 = "sha256-XI1y4pVNpXS+jqFs0KyVMrxcULOJ5rADsgvwfLF6e0Y=";
  };
  lacros-image = fetchurl {
    url =
      let
        distfiles_base = "https://commondatastorage.googleapis.com/chromeos-localmirror/distfiles";
        lacros_name = "chromeos-lacros-arm64-squash-zstd";
        lacrosVersion = "120.0.6098.0";
      in
      "${distfiles_base}/${lacros_name}-${lacrosVersion}";
    hash = "sha256-OKV8w5da9oZ1oSGbADVPCIkP9Y0MVLaQ3PXS3ZBLFXY=";
  };
in
stdenvNoCC.mkDerivation {
  name = "widevine";
  version = "4.10.2662.3";

  dontUnpack = true;
  dontBuild = true;

  buildInputs = [ python3 squashfsTools ];

  installPhase = ''
    mkdir $out
    unsquashfs -q ${lacros-image} 'WidevineCdm/*'
    python3 ${widevine-installer}/widevine_fixup.py squashfs-root/WidevineCdm/_platform_specific/cros_arm64/libwidevinecdm.so $out/libwidevinecdm.so
    mv squashfs-root/WidevineCdm/manifest.json $out/
    mv squashfs-root/WidevineCdm/LICENSE $out/
    patchelf --add-rpath ${nspr}/lib $out/libwidevinecdm.so 
  '';
}

This will propably need some structural adapting to play well with the expected browser formats. For example, firefox should be:

  programs.firefox.profiles.default.settings = {
    "media.gmp-widevinecdm.version" = pkgs.widevinecdm-aarch64.version;
    "media.gmp-widevinecdm.visible" = true;
    "media.gmp-widevinecdm.enabled" = true;
    "media.gmp-widevinecdm.autoupdate" = false;
    "media.eme.enabled" = true;
    "media.eme.encrypted-media-encryption-scheme.enabled" = true;
  };

  home.file."firefox-widevinecdm" = {
    enable = true;
    target = ".mozilla/firefox/default/gmp-widevinecdm";
    source = pkgs.runCommandLocal "firefox-widevinecdm" { } ''
      out=$out/${pkgs.widevinecdm-aarch64.version}
      mkdir -p $out
      ln -s ${pkgs.widevinecdm-aarch64}/manifest.json $out/manifest.json
      ln -s ${pkgs.widevinecdm-aarch64}/libwidevinecdm.so $out/libwidevinecdm.so
    '';
    recursive = true;
  };
dxwil commented 20 hours ago

337261