nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchYarnDeps,
6 jq,
7 yarnConfigHook,
8 nodejs,
9 jitsi-meet,
10}:
11
12let
13 pinData = import ./element-web-pin.nix;
14 inherit (pinData.hashes) webSrcHash webYarnHash webSharedComponentsYarnHash;
15 noPhoningHome = {
16 disable_guests = true; # disable automatic guest account registration at matrix.org
17 };
18 # Do not inherit jitsi-meet's knownVulnerabilities (libolm).
19 # https://github.com/NixOS/nixpkgs/pull/335753
20 # https://github.com/NixOS/nixpkgs/pull/334638
21 jitsi-meet-override = jitsi-meet.overrideAttrs (previousAttrs: {
22 meta = removeAttrs previousAttrs.meta [ "knownVulnerabilities" ];
23 });
24in
25stdenv.mkDerivation (
26 finalAttrs:
27 removeAttrs pinData [ "hashes" ]
28 // {
29 pname = "element-web";
30
31 src = fetchFromGitHub {
32 owner = "element-hq";
33 repo = "element-web";
34 rev = "v${finalAttrs.version}";
35 hash = webSrcHash;
36 };
37
38 # https://github.com/element-hq/element-web/commit/e883b05206129857aa00ca726252e10a0eb05cf9
39 # introduced a link: dependency that we need to fetch as well
40 offlineCacheSharedComponents = fetchYarnDeps {
41 yarnLock = finalAttrs.src + "/packages/shared-components/yarn.lock";
42 sha256 = webSharedComponentsYarnHash;
43 };
44
45 offlineCache = fetchYarnDeps {
46 yarnLock = finalAttrs.src + "/yarn.lock";
47 sha256 = webYarnHash;
48 };
49
50 nativeBuildInputs = [
51 yarnConfigHook
52 jq
53 nodejs
54 ];
55
56 buildPhase = ''
57 runHook preBuild
58
59 export VERSION=${finalAttrs.version}
60
61 pushd packages/shared-components
62 yarnOfflineCache=${finalAttrs.offlineCacheSharedComponents} yarnConfigHook
63 popd
64 yarn --offline --cwd packages/shared-components prepare
65
66 yarn --offline build:res
67 yarn --offline build:module_system
68 yarn --offline build:bundle
69
70 runHook postBuild
71 '';
72
73 installPhase = ''
74 runHook preInstall
75
76 cp -R webapp $out
77 cp ${jitsi-meet-override}/libs/external_api.min.js $out/jitsi_external_api.min.js
78 echo "${finalAttrs.version}" > "$out/version"
79 jq -s '.[0] * $conf' "config.sample.json" --argjson "conf" '${builtins.toJSON noPhoningHome}' > "$out/config.json"
80
81 runHook postInstall
82 '';
83
84 meta = {
85 description = "Glossy Matrix collaboration client for the web";
86 homepage = "https://element.io/";
87 changelog = "https://github.com/element-hq/element-web/blob/v${finalAttrs.version}/CHANGELOG.md";
88 teams = [ lib.teams.matrix ];
89 license = lib.licenses.agpl3Plus;
90 platforms = lib.platforms.all;
91 };
92 }
93)