nixpkgs/pkgs/applications/networking/instant-messengers/element/element-web.nix
Maximilian Bosch ad92065292
element-{web,desktop}: hack to make ofborg maintainer pings work again
Until now we had the problem that the matrix team wasn't pinged on
element changes because the version data is in a JSON and the position
of the `version`-attribute wrongly pointed to
`element-{web,desktop}.nix`:

    nix-instantiate -E 'with import ./. {}; builtins.unsafeGetAttrPos "version" element-web' --eval
    { column = 22; file = "/home/ma27/Projects/nixpkgs/pkgs/applications/networking/instant-messengers/element/element-web.nix"; line = 24; }

This is a problem because ofborg checks if modified file is part of a
derivation that got changed in a PR. I.e. only pings for element's
maintainers would be added to an element update PR if `pin.json` (which
gets modified in that case) would be recognized as file being a part of
the changed derivations (element-web/element-desktop)[1]

However, JSON imports don't propagate attribute positions (I don't know
how one would that sanely implement btw), so I decided to change
`pin.json` to a `pin.nix` and merge the relevant contents into
element-web/element-desktop.

This is kinda hacky, but as a maintainer I'd like to get modified if
somebody touches element so I can review & merge that.

With this change the position detection works fine now:

    { column = 3; file = "/home/ma27/Projects/nixpkgs/pkgs/applications/networking/instant-messengers/element/pin.nix"; line = 2; }

[1] https://github.com/NixOS/ofborg/blob/released/ofborg/src/maintainers.nix
2023-03-06 12:12:14 +01:00

88 lines
2.3 KiB
Nix

{ lib
, stdenv
, runCommand
, fetchFromGitHub
, fetchYarnDeps
, writeText
, jq
, yarn
, fixup_yarn_lock
, nodejs
, jitsi-meet
}:
let
pinData = import ./pin.nix;
inherit (pinData.hashes) webSrcHash webYarnHash;
noPhoningHome = {
disable_guests = true; # disable automatic guest account registration at matrix.org
};
in
stdenv.mkDerivation (finalAttrs: builtins.removeAttrs pinData [ "hashes" ] // {
pname = "element-web";
src = fetchFromGitHub {
owner = "vector-im";
repo = finalAttrs.pname;
rev = "v${finalAttrs.version}";
sha256 = webSrcHash;
};
offlineCache = fetchYarnDeps {
yarnLock = finalAttrs.src + "/yarn.lock";
sha256 = webYarnHash;
};
nativeBuildInputs = [ yarn fixup_yarn_lock jq nodejs ];
configurePhase = ''
runHook preConfigure
export HOME=$PWD/tmp
# with the update of openssl3, some key ciphers are not supported anymore
# this flag will allow those codecs again as a workaround
# see https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382#5f07
# and https://github.com/vector-im/element-web/issues/21043
export NODE_OPTIONS=--openssl-legacy-provider
mkdir -p $HOME
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror $offlineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
export VERSION=${finalAttrs.version}
yarn build:res --offline
yarn build:module_system --offline
yarn build:bundle --offline
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -R webapp $out
cp ${jitsi-meet}/libs/external_api.min.js $out/jitsi_external_api.min.js
echo "${finalAttrs.version}" > "$out/version"
jq -s '.[0] * $conf' "config.sample.json" --argjson "conf" '${builtins.toJSON noPhoningHome}' > "$out/config.json"
runHook postInstall
'';
meta = {
description = "A glossy Matrix collaboration client for the web";
homepage = "https://element.io/";
changelog = "https://github.com/vector-im/element-web/blob/v${finalAttrs.version}/CHANGELOG.md";
maintainers = lib.teams.matrix.members;
license = lib.licenses.asl20;
platforms = lib.platforms.all;
};
})