2021-01-25 08:26:54 +00:00
|
|
|
{ lib, fetchFromGitHub
|
2020-04-04 22:30:18 +01:00
|
|
|
, makeWrapper, makeDesktopItem, mkYarnPackage
|
2021-01-13 15:14:22 +00:00
|
|
|
, electron, element-web
|
2020-04-04 22:30:18 +01:00
|
|
|
}:
|
2019-08-26 18:07:24 +01:00
|
|
|
# Notes for maintainers:
|
2020-07-15 21:39:34 +01:00
|
|
|
# * 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 01:59:57 +00:00
|
|
|
|
|
|
|
let
|
2020-07-15 21:39:34 +01:00
|
|
|
executableName = "element-desktop";
|
2021-04-12 16:11:15 +01:00
|
|
|
version = "1.7.25";
|
2020-05-19 15:03:12 +01:00
|
|
|
src = fetchFromGitHub {
|
2019-03-18 01:59:57 +00:00
|
|
|
owner = "vector-im";
|
2020-12-09 11:26:31 +00:00
|
|
|
repo = "element-desktop";
|
2019-03-18 01:59:57 +00:00
|
|
|
rev = "v${version}";
|
2021-04-12 16:11:15 +01:00
|
|
|
sha256 = "sha256-q8hVmTLt/GdLc6NSldLggogObQcPFp+lAeS3wmO0qPo=";
|
2019-03-18 01:59:57 +00:00
|
|
|
};
|
2019-10-20 21:32:31 +01:00
|
|
|
in mkYarnPackage rec {
|
2020-07-15 21:39:34 +01:00
|
|
|
name = "element-desktop-${version}";
|
2020-05-19 15:03:12 +01:00
|
|
|
inherit version src;
|
2019-03-18 01:59:57 +00:00
|
|
|
|
2020-07-15 21:39:34 +01:00
|
|
|
packageJSON = ./element-desktop-package.json;
|
|
|
|
yarnNix = ./element-desktop-yarndeps.nix;
|
2019-03-18 01:59:57 +00:00
|
|
|
|
2020-04-11 11:05:57 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2019-03-18 01:59:57 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# resources
|
2020-07-15 21:39:34 +01:00
|
|
|
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 01:59:57 +00:00
|
|
|
|
|
|
|
# icons
|
2020-07-15 21:39:34 +01:00
|
|
|
for icon in $out/share/element/electron/build/icons/*.png; do
|
2019-03-18 01:59:57 +00:00
|
|
|
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
|
2020-07-15 21:39:34 +01:00
|
|
|
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/element.png"
|
2019-03-18 01:59:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# desktop item
|
|
|
|
mkdir -p "$out/share"
|
|
|
|
ln -s "${desktopItem}/share/applications" "$out/share/applications"
|
|
|
|
|
|
|
|
# executable wrapper
|
2020-03-05 22:16:31 +00:00
|
|
|
makeWrapper '${electron}/bin/electron' "$out/bin/${executableName}" \
|
2020-07-15 21:39:34 +01:00
|
|
|
--add-flags "$out/share/element/electron"
|
2019-03-18 01:59:57 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-15 21:39:34 +01:00
|
|
|
# Do not attempt generating a tarball for element-web again.
|
2019-03-30 22:57:59 +00:00
|
|
|
# note: `doDist = false;` does not work.
|
|
|
|
distPhase = ''
|
|
|
|
true
|
|
|
|
'';
|
|
|
|
|
2019-03-18 01:59:57 +00:00
|
|
|
# The desktop item properties should be kept in sync with data from upstream:
|
2021-01-13 15:43:26 +00:00
|
|
|
# https://github.com/vector-im/element-desktop/blob/develop/package.json
|
2019-03-18 01:59:57 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
2020-07-15 21:39:34 +01:00
|
|
|
name = "element-desktop";
|
2020-12-12 20:02:59 +00:00
|
|
|
exec = "${executableName} %u";
|
2020-07-15 21:39:34 +01:00
|
|
|
icon = "element";
|
|
|
|
desktopName = "Element (Riot)";
|
2019-03-18 01:59:57 +00:00
|
|
|
genericName = "Matrix Client";
|
|
|
|
comment = meta.description;
|
|
|
|
categories = "Network;InstantMessaging;Chat;";
|
|
|
|
extraEntries = ''
|
2020-07-15 21:39:34 +01:00
|
|
|
StartupWMClass=element
|
2020-12-12 20:02:59 +00:00
|
|
|
MimeType=x-scheme-handler/element;
|
2019-03-18 01:59:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-03-18 01:59:57 +00:00
|
|
|
description = "A feature-rich client for Matrix.org";
|
2020-07-15 21:39:34 +01:00
|
|
|
homepage = "https://element.io/";
|
2019-03-18 01:59:57 +00:00
|
|
|
license = licenses.asl20;
|
2020-06-12 02:05:26 +01:00
|
|
|
maintainers = teams.matrix.members;
|
2020-03-05 22:16:31 +00:00
|
|
|
inherit (electron.meta) platforms;
|
2019-03-18 01:59:57 +00:00
|
|
|
};
|
|
|
|
}
|