matrix-appservice-discord: 1.0.0 -> 3.1.0

- This also takes into account the transfer of the project and repository
  to the matrix-org organisation on GitHub.

- The Node version assertion has been removed because our `pkgs.nodejs`
  already points to version 18.

- This replaces the `.nix` lock file (generated with `yarn2nix`) with a
  hash-pinned fixed-output derivation, which is simpler to work with.

- This replaces the old "generate.sh" script with one that updates all the
  version info and hashes (package.json, source version, source hash,
  and Yarn dependencies hash).
  This is inspired by the update script used for the
  "matrix-appservice-slack" package.

- This switches to srcOnly for node sources.

- Added pkgs.matrix-sdk-crypto-nodejs new required native dependency.
This commit is contained in:
pacien 2022-09-13 22:34:49 +02:00 committed by Winter
parent 74f6413e44
commit 895da4caae
6 changed files with 104 additions and 4364 deletions

View file

@ -1,36 +1,54 @@
{ lib, mkYarnPackage, fetchFromGitHub, runCommand, makeWrapper, python3, nodejs, removeReferencesTo }:
assert lib.versionAtLeast nodejs.version "12.0.0";
{ lib
, mkYarnPackage
, fetchYarnDeps
, fetchFromGitHub
, srcOnly
, makeWrapper
, removeReferencesTo
, python3
, nodejs
, matrix-sdk-crypto-nodejs
}:
let
nodeSources = runCommand "node-sources" {} ''
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
mv node-* $out
'';
pin = lib.importJSON ./pin.json;
nodeSources = srcOnly nodejs;
in mkYarnPackage rec {
pname = "matrix-appservice-discord";
# when updating, run `./generate.sh <git release tag>`
version = "1.0.0";
inherit (pin) version;
src = fetchFromGitHub {
owner = "Half-Shot";
owner = "matrix-org";
repo = "matrix-appservice-discord";
rev = "v${version}";
sha256 = "0pca4jxxl4b8irvb1bacsrzjg8m7frq9dnx1knnd2n6ia3f3x545";
sha256 = pin.srcSha256;
};
packageJSON = ./package.json;
yarnNix = ./yarn-dependencies.nix;
offlineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
sha256 = pin.yarnSha256;
};
pkgConfig = {
"@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/* ./
'';
};
better-sqlite3 = {
buildInputs = [ python3 ];
nativeBuildInputs = [ python3 ];
postInstall = ''
# build native sqlite bindings
npm run build-release --offline --nodedir="${nodeSources}"
find build -type f -exec ${removeReferencesTo}/bin/remove-references-to -t "${nodeSources}" {} \;
find build -type f -exec \
${removeReferencesTo}/bin/remove-references-to \
-t "${nodeSources}" {} \;
'';
};
};
@ -57,7 +75,8 @@ in mkYarnPackage rec {
# admin tools wrappers
for toolPath in $OUT_JS_DIR/tools/*; do
makeWrapper '${nodejs}/bin/node' "$out/bin/${pname}-$(basename $toolPath .js)" \
makeWrapper '${nodejs}/bin/node' \
"$out/bin/${pname}-$(basename $toolPath .js)" \
--add-flags "$toolPath"
done
'';
@ -67,6 +86,7 @@ in mkYarnPackage rec {
passthru = {
nodeAppDir = "libexec/${pname}/deps/${pname}";
updateScript = ./update.sh;
};
meta = {

View file

@ -1,17 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../ -i bash -p wget yarn2nix
set -euo pipefail
if [ "$#" -ne 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates the Yarn dependency lock files for the matrix-appservice-discord package."
echo "Usage: $0 <git release tag>"
exit 1
fi
SRC_REPO="https://raw.githubusercontent.com/Half-Shot/matrix-appservice-discord/$1"
wget "$SRC_REPO/package.json" -O package.json
wget "$SRC_REPO/yarn.lock" -O yarn.lock
yarn2nix --lockfile=yarn.lock > yarn-dependencies.nix
rm yarn.lock

View file

@ -1,16 +1,20 @@
{
"name": "matrix-appservice-discord",
"version": "1.0.0",
"version": "3.1.0",
"description": "A bridge between Matrix and Discord",
"main": "discordas.js",
"engines": {
"npm": "please-use-yarn",
"node": ">=16 <=18"
},
"scripts": {
"test": "mocha -r ts-node/register test/config.ts test/test_*.ts test/**/test_*.ts",
"lint": "tslint --project ./tsconfig.json -t stylish",
"coverage": "nyc mocha -r ts-node/register test/config.ts test/test_*.ts test/**/test_*.ts",
"lint": "eslint -c .eslintrc --max-warnings 200 src/**/*.ts test/**/*.ts",
"coverage": "tsc && nyc mocha build/test/config.js build/test",
"build": "tsc",
"postinstall": "npm run build",
"start": "npm run-script build && node ./build/src/discordas.js -c config.yaml",
"debug": "npm run-script build && node --inspect ./build/src/discordas.js -c config.yaml",
"postinstall": "yarn build",
"start": "yarn build && node ./build/src/discordas.js -c config.yaml",
"debug": "yarn build && node --inspect ./build/src/discordas.js -c config.yaml",
"addbot": "node ./build/tools/addbot.js",
"adminme": "node ./build/tools/adminme.js",
"usertool": "node ./build/tools/userClientTools.js",
@ -36,7 +40,8 @@
},
"homepage": "https://github.com/Half-Shot/matrix-appservice-discord#readme",
"dependencies": {
"better-discord.js": "git://github.com/Sorunome/better-discord.js.git#b5a28499899fe2d9e6aa1aa3b3c5d693ae672117",
"@mx-puppet/matrix-discord-parser": "0.1.10",
"better-discord.js": "github:matrix-org/better-discord.js#5024781db755259e88abe915630b7d5b3ba5f48f",
"better-sqlite3": "^7.1.0",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
@ -44,34 +49,36 @@
"escape-string-regexp": "^4.0.0",
"js-yaml": "^3.14.0",
"marked": "^1.2.2",
"matrix-bot-sdk": "0.5.4",
"matrix-discord-parser": "0.1.5",
"matrix-appservice-bridge": "^5.0.0",
"mime": "^2.4.6",
"node-html-parser": "^1.2.19",
"p-queue": "^6.4.0",
"pg-promise": "^10.5.6",
"prom-client": "^12.0.0",
"uuid": "^8.3.1",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^4.5.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/better-sqlite3": "^5.4.1",
"@types/chai": "^4.2.11",
"@types/command-line-args": "^5.0.0",
"@types/express": "^4.17.9",
"@types/js-yaml": "^3.12.4",
"@types/marked": "^1.1.0",
"@types/mime": "^2.0.2",
"@types/mocha": "^7.0.2",
"@types/node": "^12",
"@types/better-sqlite3": "^5.4.1",
"@types/node": "^14",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"chai": "^4.2.0",
"eslint": "^7.4.0",
"mocha": "^8.0.1",
"nyc": "^15.1.0",
"proxyquire": "^1.7.11",
"source-map-support": "^0.5.19",
"ts-node": "^8.10.2",
"tslint": "^5.20.1",
"typescript": "^3.9.5",
"typescript": "^4.2.3",
"why-is-node-running": "^2.2.0"
}
}

View file

@ -0,0 +1,5 @@
{
"version": "3.1.0",
"srcSha256": "gJ093wPP0ZniOP73ZrfZzqWXNowjo/Ire8DwlgHnM1A=",
"yarnSha256": "0cm9yprj0ajmrdpap3p2lx3xrrkar6gghlxnj9127ks6p5c1ji3r"
}

View file

@ -0,0 +1,42 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../ -i bash -p nix curl jq prefetch-yarn-deps nix-prefetch-github
ORG="matrix-org"
PROJ="matrix-appservice-discord"
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for $PROJ."
echo "Usage: $0 [git release tag]"
exit 1
fi
tag="$1"
set -euo pipefail
if [ -z "$tag" ]; then
tag="$(
curl "https://api.github.com/repos/$ORG/$PROJ/releases?per_page=1" |
jq -r '.[0].tag_name'
)"
fi
src="https://raw.githubusercontent.com/$ORG/$PROJ/$tag"
src_sha256=$(nix-prefetch-github $ORG $PROJ --rev ${tag} | jq -r .sha256)
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
pushd $tmpdir
curl -O "$src/yarn.lock"
yarn_sha256=$(prefetch-yarn-deps yarn.lock)
popd
curl -O "$src/package.json"
cat > pin.json << EOF
{
"version": "$(echo $tag | grep -P '(\d|\.)+' -o)",
"srcSha256": "$src_sha256",
"yarnSha256": "$yarn_sha256"
}
EOF

File diff suppressed because it is too large Load diff