summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/networking/instant-messengers/element/element-web.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/element/element-web.nix')
-rw-r--r--pkgs/applications/networking/instant-messengers/element/element-web.nix64
1 files changed, 55 insertions, 9 deletions
diff --git a/pkgs/applications/networking/instant-messengers/element/element-web.nix b/pkgs/applications/networking/instant-messengers/element/element-web.nix
index fae96e8e5e7a..7cdfcabdce58 100644
--- a/pkgs/applications/networking/instant-messengers/element/element-web.nix
+++ b/pkgs/applications/networking/instant-messengers/element/element-web.nix
@@ -1,4 +1,15 @@
-{ lib, stdenv, fetchurl, writeText, jq, conf ? {} }:
+{ lib
+, mkYarnPackage
+, runCommand
+, fetchFromGitHub
+, fetchYarnDeps
+, writeText
+, jq
+, yarn
+, fixup_yarn_lock
+, nodejs
+, conf ? { }
+}:
let
pinData = lib.importJSON ./pin.json;
@@ -8,25 +19,61 @@ let
};
configOverrides = writeText "element-config-overrides.json" (builtins.toJSON (noPhoningHome // conf));
-in stdenv.mkDerivation rec {
+in
+mkYarnPackage rec {
pname = "element-web";
inherit (pinData) version;
- src = fetchurl {
- url = "https://github.com/vector-im/element-web/releases/download/v${version}/element-v${version}.tar.gz";
- sha256 = pinData.webHash;
+ src = fetchFromGitHub {
+ owner = "vector-im";
+ repo = pname;
+ rev = "v${version}";
+ sha256 = pinData.webSrcHash;
};
+ packageJSON = ./element-web-package.json;
+ # Remove the matrix-analytics-events dependency from the matrix-react-sdk
+ # dependencies list. It doesn't seem to be necessary since we already are
+ # installing it individually, and it causes issues with the offline mode.
+ yarnLock = (runCommand "${pname}-modified-lock" {} ''
+ sed '/matrix-analytics-events "github/d' ${src}/yarn.lock > "$out"
+ '');
+ offlineCache = fetchYarnDeps {
+ inherit yarnLock;
+ sha256 = pinData.webYarnHash;
+ };
+
+ nativeBuildInputs = [ jq ];
+
+ configurePhase = ''
+ runHook preConfigure
+ ln -s $node_modules node_modules
+ runHook postConfigure
+ '';
+
+ buildPhase = ''
+ runHook preBuild
+
+ export VERSION=${version}
+ yarn build:res --offline
+ yarn build:bundle --offline
+
+ runHook postBuild
+ '';
+
installPhase = ''
runHook preInstall
- mkdir -p $out/
- cp -R . $out/
- ${jq}/bin/jq -s '.[0] * .[1]' "config.sample.json" "${configOverrides}" > "$out/config.json"
+ cp -R webapp $out
+ echo "${version}" > "$out/version"
+ jq -s '.[0] * .[1]' "config.sample.json" "${configOverrides}" > "$out/config.json"
runHook postInstall
'';
+ # Do not attempt generating a tarball for element-web again.
+ doDist = false;
+
meta = {
description = "A glossy Matrix collaboration client for the web";
homepage = "https://element.io/";
@@ -34,6 +81,5 @@ in stdenv.mkDerivation rec {
maintainers = lib.teams.matrix.members;
license = lib.licenses.asl20;
platforms = lib.platforms.all;
- hydraPlatforms = [];
};
}