nixpkgs-suyu/pkgs/applications/networking/instant-messengers/element/element-desktop.nix

83 lines
2.5 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub
, makeWrapper, makeDesktopItem, mkYarnPackage
, electron_9, element-web
}:
# Notes for maintainers:
# * versions of `element-web` and `element-desktop` should be kept in sync.
# * the Yarn dependency expression must be updated with `./update-element-desktop.sh <git release tag>`
2019-03-18 02:59:57 +01:00
let
executableName = "element-desktop";
version = "1.7.16";
src = fetchFromGitHub {
2019-03-18 02:59:57 +01:00
owner = "vector-im";
repo = "element-desktop";
2019-03-18 02:59:57 +01:00
rev = "v${version}";
sha256 = "sha256-mdHsw1Vi+2hrAF7biX3pJqfRaZU2lpw9zUZdcCm717g=";
2019-03-18 02:59:57 +01:00
};
electron = electron_9;
2019-03-18 02:59:57 +01:00
in mkYarnPackage rec {
name = "element-desktop-${version}";
inherit version src;
2019-03-18 02:59:57 +01:00
packageJSON = ./element-desktop-package.json;
yarnNix = ./element-desktop-yarndeps.nix;
2019-03-18 02:59:57 +01:00
nativeBuildInputs = [ makeWrapper ];
2019-03-18 02:59:57 +01:00
installPhase = ''
# resources
mkdir -p "$out/share/element"
ln -s '${element-web}' "$out/share/element/webapp"
cp -r './deps/element-desktop' "$out/share/element/electron"
cp -r './deps/element-desktop/res/img' "$out/share/element"
rm "$out/share/element/electron/node_modules"
cp -r './node_modules' "$out/share/element/electron"
2019-03-18 02:59:57 +01:00
# icons
for icon in $out/share/element/electron/build/icons/*.png; do
2019-03-18 02:59:57 +01:00
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/element.png"
2019-03-18 02:59:57 +01:00
done
# desktop item
mkdir -p "$out/share"
ln -s "${desktopItem}/share/applications" "$out/share/applications"
# executable wrapper
2020-03-05 23:16:31 +01:00
makeWrapper '${electron}/bin/electron' "$out/bin/${executableName}" \
--add-flags "$out/share/element/electron"
2019-03-18 02:59:57 +01:00
'';
# Do not attempt generating a tarball for element-web again.
# note: `doDist = false;` does not work.
distPhase = ''
true
'';
2019-03-18 02:59:57 +01:00
# The desktop item properties should be kept in sync with data from upstream:
# https://github.com/vector-im/riot-desktop/blob/develop/package.json
2019-03-18 02:59:57 +01:00
desktopItem = makeDesktopItem {
name = "element-desktop";
exec = "${executableName} %u";
icon = "element";
desktopName = "Element (Riot)";
2019-03-18 02:59:57 +01:00
genericName = "Matrix Client";
comment = meta.description;
categories = "Network;InstantMessaging;Chat;";
extraEntries = ''
StartupWMClass=element
MimeType=x-scheme-handler/element;
2019-03-18 02:59:57 +01:00
'';
};
meta = with stdenv.lib; {
description = "A feature-rich client for Matrix.org";
homepage = "https://element.io/";
2019-03-18 02:59:57 +01:00
license = licenses.asl20;
2020-06-12 03:05:26 +02:00
maintainers = teams.matrix.members;
2020-03-05 23:16:31 +01:00
inherit (electron.meta) platforms;
2019-03-18 02:59:57 +01:00
};
}