From ae47403ed8b9f34e4532e5f3f234fbc88b165c10 Mon Sep 17 00:00:00 2001 From: Sean Kovacs Date: Thu, 13 Nov 2025 17:00:09 -0500 Subject: [PATCH] wip: aarch64 widevine for helium --- flake.nix | 4 +- packages/helium-browser/overlay.nix | 3 -- packages/helium-browser/package.nix | 28 +++++++---- .../helium-browser/widevine-aarch64-linux.nix | 49 +++++++++++++++++++ packages/helium-browser/widevine-meta.nix | 15 ++++++ packages/overlay.nix | 15 ++++++ packages/strawberry/overlay.nix | 3 -- packages/widevine-firefox/overlay.nix | 3 -- 8 files changed, 99 insertions(+), 21 deletions(-) delete mode 100644 packages/helium-browser/overlay.nix create mode 100644 packages/helium-browser/widevine-aarch64-linux.nix create mode 100644 packages/helium-browser/widevine-meta.nix create mode 100644 packages/overlay.nix delete mode 100644 packages/strawberry/overlay.nix delete mode 100644 packages/widevine-firefox/overlay.nix diff --git a/flake.nix b/flake.nix index e98b462..67bc88b 100644 --- a/flake.nix +++ b/flake.nix @@ -70,9 +70,7 @@ { nixpkgs.overlays = [ nur.overlays.default - (import ./packages/widevine-firefox/overlay.nix) - (import ./packages/strawberry/overlay.nix) - (import ./packages/helium-browser/overlay.nix) + (import ./packages/overlay.nix) ]; } ./system/all.nix diff --git a/packages/helium-browser/overlay.nix b/packages/helium-browser/overlay.nix deleted file mode 100644 index fbc3dc6..0000000 --- a/packages/helium-browser/overlay.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - helium-browser = prev.callPackage (builtins.path { path = ./package.nix; }) { }; -} diff --git a/packages/helium-browser/package.nix b/packages/helium-browser/package.nix index 2dd7f6b..21dac62 100644 --- a/packages/helium-browser/package.nix +++ b/packages/helium-browser/package.nix @@ -1,3 +1,7 @@ +# taken (stolen?) from two places: +# https://github.com/fpletz/flake/blob/main/pkgs/by-name/helium-browser.nix +# https://github.com/nix-community/nur-combined/blob/main/repos/Ev357/pkgs/helium/default.nix +# so shoutout those guys { stdenv, lib, @@ -5,6 +9,7 @@ fetchurl, makeDesktopItem, copyDesktopItems, + widevine-helium ? null, }: let pname = "helium-browser"; @@ -13,7 +18,7 @@ let architectures = { "x86_64-linux" = { arch = "x86_64"; - hash = lib.fakeHash; + hash = "sha256-DlEFuFwx2Qjr9eb6uiSYzM/F3r2hdtkMW5drJyJt/YE="; }; "aarch64-linux" = { arch = "arm64"; @@ -30,19 +35,24 @@ let inherit hash; }; - appimageContents = appimageTools.extractType2 { - inherit pname version src; - }; + appImageContents = appimageTools.extractType2 { inherit pname version src; }; + in appimageTools.wrapType2 { inherit pname version src; extraInstallCommands = '' - install -Dm444 ${appimageContents}/helium.desktop -t $out/share/applications - install -Dm444 ${appimageContents}/helium.png -t $out/share/pixmaps - + mkdir -p "$out/share/applications" + mkdir -p "$out/share/lib/helium" + cp -r ${appImageContents}/opt/helium/locales "$out/share/lib/helium" + cp -r ${appImageContents}/usr/share/* "$out/share" + cp "${appImageContents}/helium.desktop" "$out/share/applications/" substituteInPlace $out/share/applications/helium.desktop \ - --replace-fail 'Exec=AppRun' 'Exec=${pname}' \ - --replace-fail 'Icon=helium' 'Icon=web-browser' + --replace-fail 'Exec=AppRun' 'Exec=${pname} \ + --replace-fail 'Icon=helium' 'Icon=web-browser + + ${lib.optionalString (stdenv.hostPlatform.system == "aarch64-linux") '' + cp -r ${widevine-helium}/share/helium/WidevineCdm "$out/share/lib/helium/" + ''} ''; meta = { description = "A private, respectful browser"; diff --git a/packages/helium-browser/widevine-aarch64-linux.nix b/packages/helium-browser/widevine-aarch64-linux.nix new file mode 100644 index 0000000..94173c0 --- /dev/null +++ b/packages/helium-browser/widevine-aarch64-linux.nix @@ -0,0 +1,49 @@ +{ + lib, + stdenv, + fetchurl, + fetchFromGitHub, + squashfsTools, + python3, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "widevine-helium"; + version = "${finalAttrs.lacrosVersion}-${builtins.substring 0 7 finalAttrs.widevineInstaller.rev}"; + lacrosVersion = "120.0.6098.0"; + + widevineInstaller = fetchFromGitHub { + owner = "AsahiLinux"; + repo = "widevine-installer"; + rev = "7a3928fe1342fb07d96f61c2b094e3287588958b"; + sha256 = "sha256-XI1y4pVNpXS+jqFs0KyVMrxcULOJ5rADsgvwfLF6e0Y="; + }; + + src = fetchurl { + url = "https://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/chromeos-lacros-arm64-squash-zstd-${finalAttrs.lacrosVersion}"; + hash = "sha256-OKV8w5da9oZ1oSGbADVPCIkP9Y0MVLaQ3PXS3ZBLFXY="; + }; + + nativeBuildInputs = [ + squashfsTools + python3 + ]; + + unpackPhase = '' + unsquashfs -q $src 'WidevineCdm/*' + python3 $widevineInstaller/widevine_fixup.py squashfs-root/WidevineCdm/_platform_specific/cros_arm64/libwidevinecdm.so libwidevinecdm.so + cp squashfs-root/WidevineCdm/manifest.json . + cp squashfs-root/WidevineCdm/LICENSE LICENSE.txt + ''; + + # Accoring to widevine-installer: "Hack because Chromium hardcodes a check for this right now..." + postInstall = '' + install -vD manifest.json "$out/share/helium/WidevineCdm/manifest.json" + install -vD LICENSE.txt "$out/share/helium/WidevineCdm/License.txt" + install -vD libwidevinecdm.so "$out/share/helium/WidevineCdm/_platform_specific/linux_arm64/libwidevinecdm.so" + mkdir -p "$out/share/helium/WidevineCdm/_platform_specific/linux_x64" + touch "$out/share/helium/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so" + ''; + + meta = import ./widevine-meta.nix lib; +}) diff --git a/packages/helium-browser/widevine-meta.nix b/packages/helium-browser/widevine-meta.nix new file mode 100644 index 0000000..0bd7ee6 --- /dev/null +++ b/packages/helium-browser/widevine-meta.nix @@ -0,0 +1,15 @@ +lib: { + description = "Widevine CDM"; + homepage = "https://www.widevine.com"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ + jlamur + bearfm + ]; + platforms = lib.map (name: lib.removeSuffix ".nix" (lib.removePrefix "widevine-" name)) ( + lib.filter (name: name != "meta.nix" && name != "package.nix") ( + builtins.attrNames (builtins.readDir ./.) + ) + ); +} diff --git a/packages/overlay.nix b/packages/overlay.nix new file mode 100644 index 0000000..b6d6ceb --- /dev/null +++ b/packages/overlay.nix @@ -0,0 +1,15 @@ +final: prev: { + widevine-helium = + if prev.stdenv.hostPlatform.system == "aarch64-linux" then + prev.callPackage ./helium-browser/widevine-aarch64-linux.nix { } + else + null; + + helium-browser = prev.callPackage (builtins.path { path = ./helium-browser/package.nix; }) { }; + + strawberry-master = prev.callPackage (builtins.path { + path = ./strawberry/package.nix; + }) { }; + + widevine-firefox = prev.callPackage (builtins.path { path = ./widevine-firefox/package.nix; }) { }; +} diff --git a/packages/strawberry/overlay.nix b/packages/strawberry/overlay.nix deleted file mode 100644 index 086d41b..0000000 --- a/packages/strawberry/overlay.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - strawberry-master = prev.callPackage (builtins.path { path = ./package.nix; }) { }; -} diff --git a/packages/widevine-firefox/overlay.nix b/packages/widevine-firefox/overlay.nix deleted file mode 100644 index 2e7feb0..0000000 --- a/packages/widevine-firefox/overlay.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - widevine-firefox = prev.callPackage (builtins.path { path = ./package.nix; }) { }; -}