2022-09-13 20:34:49 +00:00
|
|
|
{ lib
|
|
|
|
, mkYarnPackage
|
|
|
|
, fetchYarnDeps
|
|
|
|
, fetchFromGitHub
|
|
|
|
, srcOnly
|
|
|
|
, makeWrapper
|
|
|
|
, removeReferencesTo
|
|
|
|
, python3
|
|
|
|
, nodejs
|
|
|
|
, matrix-sdk-crypto-nodejs
|
|
|
|
}:
|
2020-06-01 08:43:38 +00:00
|
|
|
|
|
|
|
let
|
2022-09-13 20:34:49 +00:00
|
|
|
pin = lib.importJSON ./pin.json;
|
|
|
|
nodeSources = srcOnly nodejs;
|
2020-12-27 11:56:57 +00:00
|
|
|
|
|
|
|
in mkYarnPackage rec {
|
|
|
|
pname = "matrix-appservice-discord";
|
2022-09-13 20:34:49 +00:00
|
|
|
inherit (pin) version;
|
2020-12-27 11:56:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-09-13 20:34:49 +00:00
|
|
|
owner = "matrix-org";
|
2020-12-27 11:56:57 +00:00
|
|
|
repo = "matrix-appservice-discord";
|
|
|
|
rev = "v${version}";
|
2023-07-08 06:02:51 +00:00
|
|
|
hash = pin.srcHash;
|
2020-06-01 08:43:38 +00:00
|
|
|
};
|
|
|
|
|
2020-12-27 11:56:57 +00:00
|
|
|
packageJSON = ./package.json;
|
2022-09-13 20:34:49 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = "${src}/yarn.lock";
|
|
|
|
sha256 = pin.yarnSha256;
|
|
|
|
};
|
2020-12-27 11:56:57 +00:00
|
|
|
|
|
|
|
pkgConfig = {
|
2022-09-13 20:34:49 +00:00
|
|
|
"@matrix-org/matrix-sdk-crypto-nodejs" = {
|
|
|
|
postInstall = ''
|
|
|
|
# replace with the built package
|
|
|
|
cd ..
|
|
|
|
rm -r matrix-sdk-crypto-nodejs
|
|
|
|
ln -s ${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/* ./
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-27 11:56:57 +00:00
|
|
|
better-sqlite3 = {
|
2022-09-13 20:34:49 +00:00
|
|
|
nativeBuildInputs = [ python3 ];
|
2020-12-27 11:56:57 +00:00
|
|
|
postInstall = ''
|
|
|
|
# build native sqlite bindings
|
|
|
|
npm run build-release --offline --nodedir="${nodeSources}"
|
2022-09-13 20:34:49 +00:00
|
|
|
find build -type f -exec \
|
|
|
|
${removeReferencesTo}/bin/remove-references-to \
|
|
|
|
-t "${nodeSources}" {} \;
|
2020-12-27 11:56:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
2022-11-13 17:27:13 +00:00
|
|
|
runHook preBuild
|
|
|
|
|
2020-12-27 11:56:57 +00:00
|
|
|
# compile TypeScript sources
|
|
|
|
yarn --offline build
|
2022-11-13 17:27:13 +00:00
|
|
|
|
|
|
|
runHook postBuild
|
2020-12-27 11:56:57 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
2022-11-13 17:27:13 +00:00
|
|
|
runHook preCheck
|
|
|
|
|
2021-06-06 14:09:19 +00:00
|
|
|
# the default 2000ms timeout is sometimes too short on our busy builders
|
|
|
|
yarn --offline test --timeout 10000
|
2022-11-13 17:27:13 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
2020-12-27 11:56:57 +00:00
|
|
|
'';
|
2020-06-01 08:43:38 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
2020-12-27 11:56:57 +00:00
|
|
|
OUT_JS_DIR="$out/${passthru.nodeAppDir}/build"
|
2020-06-01 08:43:38 +00:00
|
|
|
|
|
|
|
# server wrapper
|
2020-12-27 11:56:57 +00:00
|
|
|
makeWrapper '${nodejs}/bin/node' "$out/bin/${pname}" \
|
|
|
|
--add-flags "$OUT_JS_DIR/src/discordas.js"
|
2020-06-01 08:43:38 +00:00
|
|
|
|
|
|
|
# admin tools wrappers
|
2020-12-27 11:56:57 +00:00
|
|
|
for toolPath in $OUT_JS_DIR/tools/*; do
|
2022-09-13 20:34:49 +00:00
|
|
|
makeWrapper '${nodejs}/bin/node' \
|
|
|
|
"$out/bin/${pname}-$(basename $toolPath .js)" \
|
2020-06-01 08:43:38 +00:00
|
|
|
--add-flags "$toolPath"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2020-12-27 11:56:57 +00:00
|
|
|
# don't generate the dist tarball
|
2022-05-31 15:10:16 +00:00
|
|
|
doDist = false;
|
2020-12-27 11:56:57 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
nodeAppDir = "libexec/${pname}/deps/${pname}";
|
2022-09-13 20:34:49 +00:00
|
|
|
updateScript = ./update.sh;
|
2020-12-27 11:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Bridge between Matrix and Discord";
|
|
|
|
homepage = "https://github.com/Half-Shot/matrix-appservice-discord";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ pacien ];
|
|
|
|
platforms = lib.platforms.linux;
|
2023-12-11 20:45:14 +00:00
|
|
|
mainProgram = "matrix-appservice-discord";
|
2020-12-27 11:56:57 +00:00
|
|
|
};
|
2020-06-01 08:43:38 +00:00
|
|
|
}
|