Merge pull request #196885 from linsui/element-web

This commit is contained in:
Sandro 2022-11-07 20:09:43 +01:00 committed by GitHub
commit 5ff52d0441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,9 +18,8 @@ let
disable_guests = true; # disable automatic guest account registration at matrix.org disable_guests = true; # disable automatic guest account registration at matrix.org
piwik = false; # disable analytics piwik = false; # disable analytics
}; };
configOverrides = writeText "element-config-overrides.json" (builtins.toJSON (noPhoningHome // conf));
in stdenv.mkDerivation rec { unwrapped = stdenv.mkDerivation rec {
pname = "element-web"; pname = "element-web";
inherit (pinData) version; inherit (pinData) version;
@ -74,7 +73,7 @@ in stdenv.mkDerivation rec {
cp -R webapp $out cp -R webapp $out
cp ${jitsi-meet}/libs/external_api.min.js $out/jitsi_external_api.min.js cp ${jitsi-meet}/libs/external_api.min.js $out/jitsi_external_api.min.js
echo "${version}" > "$out/version" echo "${version}" > "$out/version"
jq -s '.[0] * .[1]' "config.sample.json" "${configOverrides}" > "$out/config.json" jq -s '.[0] * $conf' "config.sample.json" --argjson "conf" '${builtins.toJSON noPhoningHome}' > "$out/config.json"
runHook postInstall runHook postInstall
''; '';
@ -87,4 +86,25 @@ in stdenv.mkDerivation rec {
license = lib.licenses.asl20; license = lib.licenses.asl20;
platforms = lib.platforms.all; platforms = lib.platforms.all;
}; };
};
in
if (conf == { }) then unwrapped else
stdenv.mkDerivation rec {
pname = "${unwrapped.pname}-wrapped";
inherit (unwrapped) version meta;
dontUnpack = true;
nativeBuildInputs = [ jq ];
installPhase = ''
runHook preInstall
mkdir -p $out
ln -s ${unwrapped}/* $out
rm $out/config.json
jq -s '.[0] * $conf' "${unwrapped}/config.json" --argjson "conf" '${builtins.toJSON conf}' > "$out/config.json"
runHook postInstall
'';
} }