Skip to content

Instantly share code, notes, and snippets.

@afilini
Created January 18, 2024 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afilini/7fb5624c850f39af4938f4a5d087f2dc to your computer and use it in GitHub Desktop.
Save afilini/7fb5624c850f39af4938f4a5d087f2dc to your computer and use it in GitHub Desktop.
Repackaging of "widevine-installer" from AsahiLinux for NixOS
let
pkgs = import <nixpkgs> {};
lacrosVersion = "120.0.6098.0";
widevine-installer = pkgs.stdenv.mkDerivation rec {
name = "widevine-installer";
version = "7a3928fe1342fb07d96f61c2b094e3287588958b";
src = pkgs.fetchFromGitHub {
owner = "AsahiLinux";
repo = "${name}";
rev = "${version}";
sha256 = "sha256-XI1y4pVNpXS+jqFs0KyVMrxcULOJ5rADsgvwfLF6e0Y=";
};
buildInputs = with 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 = pkgs.stdenv.mkDerivation {
name = "widevine";
version = "";
buildInputs = with pkgs; [ curl widevine-installer ];
src = pkgs.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 = pkgs.runCommand "chromium-wv" { version = pkgs.chromium.version; }
''
mkdir -p $out
cp -a ${pkgs.chromium.browser}/* $out/
chmod u+w $out/libexec/chromium
cp -Lr ${widevine}/WidevineCdm $out/libexec/chromium/
'';
chromiumWidevineWrapper = pkgs.chromium.overrideAttrs (prev: {
buildCommand = builtins.replaceStrings [ "${pkgs.chromium.browser}" ] [ "${chromiumWV}" ] prev.buildCommand;
});
in
pkgs.mkShell {
buildInputs = [
chromiumWidevineWrapper
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment