Created
January 22, 2024 23:13
-
-
Save psanford/1f70a0838c308d28478cf27a9b55c43d to your computer and use it in GitHub Desktop.
Overlay for chromium widevine support with 16k pages (asahi on m{1,2,3} macs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final: prev: | |
let | |
lacrosVersion = "120.0.6098.0"; | |
widevine-installer = prev.stdenv.mkDerivation rec { | |
name = "widevine-installer"; | |
version = "7a3928fe1342fb07d96f61c2b094e3287588958b"; | |
src = prev.fetchFromGitHub { | |
owner = "AsahiLinux"; | |
repo = "${name}"; | |
rev = "${version}"; | |
sha256 = "sha256-XI1y4pVNpXS+jqFs0KyVMrxcULOJ5rADsgvwfLF6e0Y="; | |
}; | |
buildInputs = with prev.pkgs; [ which python3 squashfsTools ]; | |
installPhase = '' | |
mkdir -p "$out/bin" | |
cp widevine-installer "$out/bin/" | |
cp widevine_fixup.py "$out/bin/" | |
echo "$(which unsquashfs)" | |
sed -e "s|unsquashfs|$(which unsquashfs)|" -i "$out/bin/widevine-installer" | |
sed -e "s|python3|$(which python3)|" -i "$out/bin/widevine-installer" | |
sed -e "s|read|#read|" -i "$out/bin/widevine-installer" | |
sed -e 's|$(whoami)|root|' -i "$out/bin/widevine-installer" | |
sed -e 's|URL=.*|URL="$DISTFILES_BASE"|' -i "$out/bin/widevine-installer" | |
''; | |
}; | |
widevine = prev.stdenv.mkDerivation { | |
name = "widevine"; | |
version = ""; | |
buildInputs = with prev.pkgs; [ curl widevine-installer ]; | |
src = prev.fetchurl { | |
urls = [ "https://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/chromeos-lacros-arm64-squash-zstd-${lacrosVersion}" ]; | |
hash = "sha256-OKV8w5da9oZ1oSGbADVPCIkP9Y0MVLaQ3PXS3ZBLFXY="; | |
}; | |
unpackPhase = "true"; | |
installPhase = '' | |
mkdir -p "$out/" | |
COPY_CONFIGS=0 INSTALL_BASE="$out" DISTFILES_BASE="file://$src" widevine-installer | |
''; | |
}; | |
chromiumWV = prev.runCommand "chromium-wv" { version = prev.chromium.version; } | |
'' | |
mkdir -p $out | |
cp -a ${prev.chromium.browser}/* $out/ | |
chmod u+w $out/libexec/chromium | |
cp -Lr ${widevine}/WidevineCdm $out/libexec/chromium/ | |
''; | |
in | |
{ | |
chromium = prev.chromium.overrideAttrs (old: { | |
buildCommand = builtins.replaceStrings [ "${prev.chromium.browser}" ] [ "${chromiumWV}" ] old.buildCommand; | |
}); | |
} |
Working off of @diegobfernandez version, I wrapped the environmental variable right into firefox. Also modified the way extraPrefsFiles get applied, because for me the way it's now written did not work whatever I tried, something might be wrong in the firefox wrapper iteself.
@@ -15,8 +15,10 @@
installPhase = ''
mkdir -p "$out/bin"
+ mkdir -p "$out/conf"
cp widevine-installer "$out/bin/"
cp widevine_fixup.py "$out/bin/"
+ cp conf/gmpwidevine.js "$out/conf/"
echo "$(which unsquashfs)"
sed -e "s|unsquashfs|$(which unsquashfs)|" -i "$out/bin/widevine-installer"
sed -e "s|python3|$(which python3)|" -i "$out/bin/widevine-installer"
@@ -50,6 +52,14 @@
'';
in
{
+ firefox = prev.firefox.overrideAttrs (old: {
+ buildCommand = old.buildCommand + ''
+ cat ${widevine-installer}/conf/gmpwidevine.js >> "$out/lib/firefox/mozilla.cfg"
+
+ wrapProgram "$oldExe" \
+ --set MOZ_GMP_PATH "${widevine}/gmp-widevinecdm/system-installed"
+ '';
+ });
chromium = prev.chromium.overrideAttrs (old: {
buildCommand = builtins.replaceStrings [ "${prev.chromium.browser}" ] [ "${chromiumWV}" ] old.buildCommand;
});
For firefox, it should now be as simple as enabling the overlay, enjoy!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've made these changes to make it work on Firefox:
widevine
is there so I can addto my
configuration.nix
.If anyone knows a way to set the environment variable on the package it would be great and make the overlay work on its own.