rambox: migrate to use AppImage

The motivation comes from PR #108787: AppImage is the official and
using it should avoid some issues.

Also, migrating both packages (instead of only rambox-pro like #108787)
can make maintaining both packages better. There is now a `mkRambox`
function that abstract most of the build process.
This commit is contained in:
Thiago Kenji Okada 2021-01-11 11:15:12 -03:00
parent 5ac7aa579a
commit 530f90d862
3 changed files with 50 additions and 75 deletions

View File

@ -1,46 +1,22 @@
{ stdenv, lib, fetchurl, xdg_utils, dpkg, makeWrapper, autoPatchelfHook
, libXtst, libXScrnSaver, gtk3, nss, alsaLib, udev, libnotify, wrapGAppsHook
}:
{ stdenv, callPackage, fetchurl, lib }:
let
version = "0.7.7";
in stdenv.mkDerivation rec {
mkRambox = opts: callPackage (import ./rambox.nix opts) { };
in mkRambox rec {
pname = "rambox";
inherit version;
version = "0.7.7";
src = {
x86_64-linux = fetchurl {
url = "https://github.com/ramboxapp/community-edition/releases/download/${version}/Rambox-${version}-linux-amd64.deb";
sha256 = "0bij4f1bkg94gc8pq7r6yfym5zcvwc2ymdnmnmh5m4h1pa1gk6x9";
url = "https://github.com/ramboxapp/community-edition/releases/download/${version}/Rambox-${version}-linux-x86_64.AppImage";
sha256 = "0f82hq0dzcjicdz6lkzj8889y100yqciqrwh8wjjy9pxkhjcdini";
};
i686-linux = fetchurl {
url = "https://github.com/ramboxapp/community-edition/releases/download/${version}/Rambox-${version}-linux-i386.deb";
sha256 = "1nhgqjha10jvyf9nsghvlkibg7byj8qz140639ygag9qlpd51rfs";
url = "https://github.com/ramboxapp/community-edition/releases/download/${version}/Rambox-${version}-linux-i386.AppImage";
sha256 = "1nhgqjha10jvyf9nsghvlkibg7byj8qz140639ygag9qlpd52rfs";
};
}.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook wrapGAppsHook ];
buildInputs = [ libXtst libXScrnSaver gtk3 nss alsaLib ];
runtimeDependencies = [ (lib.getLib udev) libnotify ];
unpackPhase = "dpkg-deb -x $src .";
installPhase = ''
mkdir -p $out/bin
cp -r opt $out
ln -s $out/opt/Rambox/rambox $out/bin
# provide resources
cp -r usr/share $out
substituteInPlace $out/share/applications/rambox.desktop \
--replace Exec=/opt/Rambox/rambox Exec=rambox
'';
preFixup = ''
gappsWrapperArgs+=(
--prefix PATH : ${xdg_utils}/bin
)
'';
meta = with lib; {
description = "Free and Open Source messaging and emailing app that combines common web applications into one";
homepage = "https://rambox.pro";

View File

@ -1,56 +1,25 @@
{ autoPatchelfHook, electron_7, fetchurl, makeDesktopItem, makeWrapper, nodePackages, nss, lib, stdenv, xdg_utils, xorg }:
{ stdenv, callPackage, fetchurl, lib }:
let
electron = electron_7;
in
stdenv.mkDerivation rec {
mkRambox = opts: callPackage (import ./rambox.nix opts) { };
in mkRambox rec {
pname = "rambox-pro";
version = "1.4.1";
dontBuild = true;
dontStrip = true;
desktopName = "Rambox Pro";
buildInputs = [ nss xorg.libXext xorg.libxkbfile xorg.libXScrnSaver ];
nativeBuildInputs = [ autoPatchelfHook makeWrapper nodePackages.asar ];
src = fetchurl {
url = "https://github.com/ramboxapp/download/releases/download/v${version}/RamboxPro-${version}-linux-x64.tar.gz";
sha256 = "1bd4fba3ac8c20fa557ebfb110f6503d36e6c3dba0401d1073529dcae2c2ec1e";
};
installPhase = ''
mkdir -p $out/{bin,resources/dist/renderer/assets/images/app,share/applications,share/icons/hicolor/256x256/apps}
asar e resources/app.asar $out/resources
substituteInPlace "$out/resources/dist/electron/main.js" \
--replace ",isHidden:" ",path:\"$out/bin/ramboxpro\",isHidden:"
cp $desktopItem/share/applications/* $out/share/applications
cp $out/resources/dist/electron/imgs/256x256.png $out/share/icons/hicolor/256x256/apps/ramboxpro.png
cp $out/resources/dist/electron/imgs/256x256.png $out/resources/dist/renderer/assets/images/app/icon.png
'';
postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/ramboxpro \
--add-flags "$out/resources --without-update" \
--prefix PATH : ${xdg_utils}/bin
'';
desktopItem = makeDesktopItem {
name = "rambox-pro";
exec = "ramboxpro";
icon = "ramboxpro";
type = "Application";
desktopName = "Rambox Pro";
categories = "Network;";
};
src = {
x86_64-linux = fetchurl {
url = "https://github.com/ramboxapp/download/releases/download/v${version}/RamboxPro-${version}-linux-x64.AppImage";
sha256 = "18383v3g26hd1czvw06gmjn8bdw2w9c7zb04zkfl6szgakrv26x4";
};
}.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
meta = with lib; {
description = "Messaging and emailing app that combines common web applications into one";
homepage = "https://rambox.pro";
license = licenses.unfree;
maintainers = with maintainers; [ chrisaw ];
platforms = [ "i686-linux" "x86_64-linux" ];
platforms = [ "x86_64-linux" ];
};
}

View File

@ -0,0 +1,30 @@
{ pname, version, src, meta, desktopName ? "Rambox" }:
{ appimageTools, stdenv, lib, fetchurl, makeDesktopItem }:
let
name = "${pname}-${version}";
desktopItem = (makeDesktopItem {
inherit desktopName;
name = pname;
exec = pname;
icon = pname;
type = "Application";
categories = "Network;";
});
appimageContents = appimageTools.extractType2 {
inherit name src;
};
in appimageTools.wrapType2 rec {
inherit name src meta;
extraInstallCommands = ''
mkdir -p $out/share/applications $out/share/icons/hicolor/256x256/apps
# CE uses rambox-<version>, Pro uses rambox
mv $out/bin/rambox* $out/bin/${pname}
install -Dm644 ${appimageContents}/usr/share/icons/hicolor/256x256/apps/rambox*.png $out/share/icons/hicolor/256x256/apps/${pname}.png
install -Dm644 ${desktopItem}/share/applications/* $out/share/applications
'';
}