From 530f90d8625a75261ad502db796f221d315993a4 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 11 Jan 2021 11:15:12 -0300 Subject: [PATCH] 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. --- .../instant-messengers/rambox/default.nix | 42 ++++----------- .../instant-messengers/rambox/pro.nix | 53 ++++--------------- .../instant-messengers/rambox/rambox.nix | 30 +++++++++++ 3 files changed, 50 insertions(+), 75 deletions(-) create mode 100644 pkgs/applications/networking/instant-messengers/rambox/rambox.nix diff --git a/pkgs/applications/networking/instant-messengers/rambox/default.nix b/pkgs/applications/networking/instant-messengers/rambox/default.nix index bc26b68d2db7..5525805c2e4c 100644 --- a/pkgs/applications/networking/instant-messengers/rambox/default.nix +++ b/pkgs/applications/networking/instant-messengers/rambox/default.nix @@ -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"; diff --git a/pkgs/applications/networking/instant-messengers/rambox/pro.nix b/pkgs/applications/networking/instant-messengers/rambox/pro.nix index 1df0b597ae24..7051799a2775 100644 --- a/pkgs/applications/networking/instant-messengers/rambox/pro.nix +++ b/pkgs/applications/networking/instant-messengers/rambox/pro.nix @@ -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" ]; }; } diff --git a/pkgs/applications/networking/instant-messengers/rambox/rambox.nix b/pkgs/applications/networking/instant-messengers/rambox/rambox.nix new file mode 100644 index 000000000000..6881ae270f9b --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/rambox/rambox.nix @@ -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-, 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 + ''; +}