switch helium-browser to non-appimage

This commit is contained in:
Sean Kovacs 2025-11-13 17:54:50 -05:00
commit a7a25b1d7b
Signed by: sckova
GPG key ID: 00F325187C68651A

View file

@ -1,65 +1,126 @@
# 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, stdenv,
lib, lib,
appimageTools,
fetchurl, fetchurl,
makeDesktopItem, makeDesktopItem,
copyDesktopItems, copyDesktopItems,
widevine-helium ? null, autoPatchelfHook,
makeWrapper,
# runtime dependencies
xorg,
libGL,
mesa,
cairo,
pango,
systemd,
alsa-lib,
gcc-unwrapped,
qt5,
qt6,
glib,
nspr,
nss,
at-spi2-atk,
at-spi2-core,
cups,
}: }:
let let
pname = "helium-browser";
version = "0.6.4.1";
architectures = { architectures = {
"x86_64-linux" = { "x86_64-linux" = {
arch = "x86_64"; arch = "x86_64";
hash = "sha256-DlEFuFwx2Qjr9eb6uiSYzM/F3r2hdtkMW5drJyJt/YE="; hash = "sha256-9xEVnGym579rR6RunS4HWYV3nLk1ODEIGfg8PtNDSUk=";
}; };
"aarch64-linux" = { "aarch64-linux" = {
arch = "arm64"; arch = "arm64";
hash = "sha256-B63tvOtSRlMRJozvzC7lqG2LM0ZgLIq2G/AHABl+Qqg="; hash = "sha256-S5kF+K2Kwhqa0GG691NvnU/2frUCWL9BKrVK7y3bzSE=";
}; };
}; };
src = platformInfo =
let architectures.${stdenv.hostPlatform.system}
inherit (architectures.${stdenv.hostPlatform.system}) arch hash; or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
fetchurl {
url = "https://github.com/imputnet/helium-linux/releases/download/${version}/helium-${version}-${arch}.AppImage";
inherit hash;
};
appImageContents = appimageTools.extractType2 { inherit pname version src; };
in in
appimageTools.wrapType2 { stdenv.mkDerivation rec {
inherit pname version src; pname = "helium-browser";
extraInstallCommands = '' version = "0.6.4.1";
mkdir -p "$out/share/applications" xzName = "helium-${version}-${platformInfo.arch}_linux";
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
${lib.optionalString (stdenv.hostPlatform.system == "aarch64-linux") '' src = fetchurl {
cp -r ${widevine-helium}/share/helium/WidevineCdm "$out/share/lib/helium/" url = "https://github.com/imputnet/helium-linux/releases/download/${version}/${xzName}.tar.xz";
''} hash = platformInfo.hash;
};
sourceRoot = ".";
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
copyDesktopItems
];
buildInputs = [
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxcb
xorg.libXdamage
xorg.libXcomposite
mesa
cairo
pango
systemd
alsa-lib
gcc-unwrapped.lib
qt5.qtbase.out
qt6.qtbase.out
glib
nspr
nss
at-spi2-atk
at-spi2-core
cups
];
dontWrapQtApps = true;
unpackPhase = ''
runHook preUnpack
tar xf $src
runHook postUnpack
''; '';
meta = {
description = "A private, respectful browser"; installPhase = ''
homepage = "https://github.com/imputnet/helium-linux"; runHook preInstall
downloadPage = "https://github.com/imputnet/helium-linux/releases";
license = lib.licenses.gpl3Only; mkdir -p $out/opt/helium
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; mv ${xzName}/helium.desktop .
platforms = lib.attrNames architectures; mv ${xzName}/product_logo_256.png .
cp -r ${xzName}/* $out/opt/helium/
chmod +x $out/opt/helium/chrome-wrapper $out/opt/helium/chrome
makeWrapper $out/opt/helium/chrome-wrapper $out/bin/helium-browser \
--chdir $out/opt/helium \
--prefix LD_LIBRARY_PATH : "${
lib.makeLibraryPath [
libGL
mesa
]
}"
install -Dm644 product_logo_256.png $out/share/icons/hicolor/256x256/apps/helium.png
install -Dm644 helium.desktop $out/share/applications/helium.desktop
substituteInPlace $out/share/applications/helium.desktop \
--replace-fail 'Exec=chromium' "Exec=$out/bin/helium-browser" \
runHook postInstall
'';
meta = with lib; {
homepage = "https://helium.computer";
description = "Helium web browser";
platforms = platforms.linux;
mainProgram = "helium";
}; };
} }