2021-08-05 10:02:30 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, makeDesktopItem
|
|
|
|
, mkYarnPackage
|
2021-10-12 21:58:14 +00:00
|
|
|
, fetchYarnDeps
|
2021-08-05 10:02:30 +00:00
|
|
|
, electron
|
|
|
|
, element-web
|
2022-01-02 23:28:13 +00:00
|
|
|
, sqlcipher
|
2021-08-03 22:08:53 +00:00
|
|
|
, callPackage
|
2021-08-04 09:09:56 +00:00
|
|
|
, Security
|
|
|
|
, AppKit
|
|
|
|
, CoreServices
|
2021-07-28 21:31:09 +00:00
|
|
|
, desktopToDarwinBundle
|
2022-02-11 13:26:07 +00:00
|
|
|
, useKeytar ? true
|
2020-04-04 21:30:18 +00:00
|
|
|
}:
|
2019-03-18 01:59:57 +00:00
|
|
|
|
|
|
|
let
|
2021-11-03 12:43:23 +00:00
|
|
|
pinData = lib.importJSON ./pin.json;
|
2020-07-15 20:39:34 +00:00
|
|
|
executableName = "element-desktop";
|
2021-10-12 21:58:14 +00:00
|
|
|
electron_exec = if stdenv.isDarwin then "${electron}/Applications/Electron.app/Contents/MacOS/Electron" else "${electron}/bin/electron";
|
2022-02-11 13:26:07 +00:00
|
|
|
keytar = callPackage ./keytar { inherit Security AppKit; };
|
|
|
|
seshat = callPackage ./seshat { inherit CoreServices; };
|
2021-10-12 21:58:14 +00:00
|
|
|
in
|
|
|
|
mkYarnPackage rec {
|
|
|
|
pname = "element-desktop";
|
|
|
|
inherit (pinData) version;
|
|
|
|
name = "${pname}-${version}";
|
2020-05-19 14:03:12 +00: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-10-12 21:58:14 +00:00
|
|
|
sha256 = pinData.desktopSrcHash;
|
2019-03-18 01:59:57 +00:00
|
|
|
};
|
|
|
|
|
2020-07-15 20:39:34 +00:00
|
|
|
packageJSON = ./element-desktop-package.json;
|
2021-10-12 21:58:14 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
|
|
|
sha256 = pinData.desktopYarnHash;
|
|
|
|
};
|
2019-03-18 01:59:57 +00:00
|
|
|
|
2021-07-28 21:31:09 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
|
2019-03-18 01:59:57 +00:00
|
|
|
|
2022-02-11 13:26:07 +00:00
|
|
|
inherit seshat;
|
2021-08-03 22:08:53 +00:00
|
|
|
|
2021-07-23 10:13:29 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
pushd deps/element-desktop/
|
|
|
|
npx tsc
|
2021-07-23 17:07:52 +00:00
|
|
|
yarn run i18n
|
|
|
|
node ./scripts/copy-res.js
|
2021-07-23 10:13:29 +00:00
|
|
|
popd
|
2021-08-03 22:08:53 +00:00
|
|
|
rm -rf node_modules/matrix-seshat node_modules/keytar
|
2022-02-11 13:26:07 +00:00
|
|
|
${lib.optionalString useKeytar "ln -s ${keytar} node_modules/keytar"}
|
2021-08-03 22:08:53 +00:00
|
|
|
ln -s $seshat node_modules/matrix-seshat
|
2021-07-23 10:13:29 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2019-03-18 01:59:57 +00:00
|
|
|
installPhase = ''
|
2022-02-11 13:26:07 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2019-03-18 01:59:57 +00:00
|
|
|
# resources
|
2020-07-15 20:39:34 +00: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"
|
2021-07-23 17:07:52 +00:00
|
|
|
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
|
2021-08-06 01:59:24 +00:00
|
|
|
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
|
2019-03-18 01:59:57 +00:00
|
|
|
|
|
|
|
# icons
|
2020-07-15 20:39:34 +00: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 20:39:34 +00: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
|
2022-01-02 23:28:13 +00:00
|
|
|
# LD_PRELOAD workaround for sqlcipher not found: https://github.com/matrix-org/seshat/issues/102
|
2021-08-04 09:58:29 +00:00
|
|
|
makeWrapper '${electron_exec}' "$out/bin/${executableName}" \
|
2022-01-02 23:28:13 +00:00
|
|
|
--set LD_PRELOAD ${sqlcipher}/lib/libsqlcipher.so \
|
2021-11-27 00:54:14 +00:00
|
|
|
--add-flags "$out/share/element/electron" \
|
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
|
2022-02-11 13:26:07 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2019-03-18 01:59:57 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-15 20:39:34 +00: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 20:39:34 +00:00
|
|
|
name = "element-desktop";
|
2020-12-12 20:02:59 +00:00
|
|
|
exec = "${executableName} %u";
|
2020-07-15 20:39:34 +00:00
|
|
|
icon = "element";
|
2022-01-02 23:28:13 +00:00
|
|
|
desktopName = "Element";
|
2019-03-18 01:59:57 +00:00
|
|
|
genericName = "Matrix Client";
|
|
|
|
comment = meta.description;
|
|
|
|
categories = "Network;InstantMessaging;Chat;";
|
|
|
|
extraEntries = ''
|
2020-07-15 20:39:34 +00:00
|
|
|
StartupWMClass=element
|
2020-12-12 20:02:59 +00:00
|
|
|
MimeType=x-scheme-handler/element;
|
2019-03-18 01:59:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-02-11 13:26:07 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
|
|
|
|
# TL;DR: keytar is optional while seshat isn't.
|
|
|
|
#
|
|
|
|
# This prevents building keytar when `useKeytar` is set to `false`, because
|
|
|
|
# if libsecret is unavailable (e.g. set to `null` or fails to build), then
|
|
|
|
# this package wouldn't even considered for building because
|
|
|
|
# "one of the dependencies failed to build",
|
|
|
|
# although the dependency wouldn't even be used.
|
|
|
|
#
|
|
|
|
# It needs to be `passthru` anyways because other packages do depend on it.
|
|
|
|
inherit keytar;
|
|
|
|
};
|
2021-10-12 21:58:14 +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 20:39:34 +00:00
|
|
|
homepage = "https://element.io/";
|
2021-04-26 18:01:34 +00:00
|
|
|
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 01:05:26 +00: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
|
|
|
};
|
|
|
|
}
|