3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/networking/instant-messengers/element/element-desktop.nix

114 lines
3.5 KiB
Nix
Raw Normal View History

2021-08-05 11:02:30 +01:00
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, makeDesktopItem
, mkYarnPackage
, electron
, element-web
2021-08-03 23:08:53 +01:00
, callPackage
, Security
, AppKit
, CoreServices
, useWayland ? false
}:
# 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 01:59:57 +00:00
let
executableName = "element-desktop";
version = "1.9.2";
src = fetchFromGitHub {
2019-03-18 01:59:57 +00:00
owner = "vector-im";
repo = "element-desktop";
2019-03-18 01:59:57 +00:00
rev = "v${version}";
sha256 = "sha256-F1uyyBbs+U7tQzRtn+p923Z/BY8Nwxr/JTMYwsak8W8=";
2019-03-18 01:59:57 +00:00
};
electron_exec = if stdenv.isDarwin then "${electron}/Applications/Electron.app/Contents/MacOS/Electron" else "${electron}/bin/electron";
2021-08-05 11:02:30 +01:00
in
mkYarnPackage rec {
name = "element-desktop-${version}";
inherit version src;
2019-03-18 01:59:57 +00:00
packageJSON = ./element-desktop-package.json;
yarnNix = ./element-desktop-yarndeps.nix;
2019-03-18 01:59:57 +00:00
nativeBuildInputs = [ makeWrapper ];
2019-03-18 01:59:57 +00:00
seshat = callPackage ./seshat { inherit CoreServices; };
keytar = callPackage ./keytar { inherit Security AppKit; };
2021-08-03 23:08:53 +01:00
buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
pushd deps/element-desktop/
npx tsc
yarn run i18n
node ./scripts/copy-res.js
popd
2021-08-03 23:08:53 +01:00
rm -rf node_modules/matrix-seshat node_modules/keytar
ln -s $keytar node_modules/keytar
ln -s $seshat node_modules/matrix-seshat
runHook postBuild
'';
2019-03-18 01:59:57 +00: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"
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
2021-08-06 02:59:24 +01:00
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
2019-03-18 01:59:57 +00:00
# icons
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"
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
makeWrapper '${electron_exec}' "$out/bin/${executableName}" \
--add-flags "$out/share/element/electron${lib.optionalString useWayland " --enable-features=UseOzonePlatform --ozone-platform=wayland"}"
2019-03-18 01:59:57 +00:00
'';
# Do not attempt generating a tarball for element-web again.
# 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:
# https://github.com/vector-im/element-desktop/blob/develop/package.json
2019-03-18 01:59:57 +00:00
desktopItem = makeDesktopItem {
name = "element-desktop";
exec = "${executableName} %u";
icon = "element";
desktopName = "Element (Riot)";
2019-03-18 01:59:57 +00:00
genericName = "Matrix Client";
comment = meta.description;
categories = "Network;InstantMessaging;Chat;";
extraEntries = ''
StartupWMClass=element
MimeType=x-scheme-handler/element;
2019-03-18 01:59:57 +00:00
'';
};
meta = with lib; {
2019-03-18 01:59:57 +00:00
description = "A feature-rich client for Matrix.org";
homepage = "https://element.io/";
changelog = "https://github.com/vector-im/element-desktop/blob/v${version}/CHANGELOG.md";
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
};
}