matrix-appservice-discord: 0.5.2 -> 1.0.0

Upstream now uses Yarn instead of NPM, so we now use yarn2nix instead of
node2nix.
This commit is contained in:
pacien 2020-12-27 12:56:57 +01:00
parent 2afec82bf8
commit 9474df2285
6 changed files with 4475 additions and 5294 deletions

View file

@ -1,29 +1,80 @@
{ pkgs, nodejs, stdenv }:
{ lib, mkYarnPackage, fetchFromGitHub, runCommand, makeWrapper, python, nodejs }:
assert lib.versionAtLeast nodejs.version "12.0.0";
let
nodePackages = import ./node-composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
nodeSources = runCommand "node-sources" {} ''
tar --no-same-owner --no-same-permissions -xf "${nodejs.src}"
mv node-* $out
'';
in mkYarnPackage rec {
pname = "matrix-appservice-discord";
# when updating, run `./generate.sh <git release tag>`
version = "1.0.0";
src = fetchFromGitHub {
owner = "Half-Shot";
repo = "matrix-appservice-discord";
rev = "v${version}";
sha256 = "0pca4jxxl4b8irvb1bacsrzjg8m7frq9dnx1knnd2n6ia3f3x545";
};
in nodePackages."matrix-appservice-discord-git+https://github.com/Half-Shot/matrix-appservice-discord.git#v0.5.2".override {
nativeBuildInputs = [ pkgs.makeWrapper ];
packageJSON = ./package.json;
yarnNix = ./yarn-dependencies.nix;
pkgConfig = {
better-sqlite3 = {
buildInputs = [ python ];
postInstall = ''
# build native sqlite bindings
npm run build-release --offline --nodedir="${nodeSources}"
'';
};
};
nativeBuildInputs = [ makeWrapper ];
buildPhase = ''
# compile TypeScript sources
yarn --offline build
'';
doCheck = true;
checkPhase = ''
yarn --offline test
'';
postInstall = ''
# compile Typescript sources
npm run build
OUT_JS_DIR="$out/${passthru.nodeAppDir}/build"
# server wrapper
makeWrapper '${nodejs}/bin/node' "$out/bin/matrix-appservice-discord" \
--add-flags "$out/lib/node_modules/matrix-appservice-discord/build/src/discordas.js"
makeWrapper '${nodejs}/bin/node' "$out/bin/${pname}" \
--add-flags "$OUT_JS_DIR/src/discordas.js"
# admin tools wrappers
for toolPath in $out/lib/node_modules/matrix-appservice-discord/build/tools/*; do
makeWrapper '${nodejs}/bin/node' "$out/bin/matrix-appservice-discord-$(basename $toolPath .js)" \
for toolPath in $OUT_JS_DIR/tools/*; do
makeWrapper '${nodejs}/bin/node' "$out/bin/${pname}-$(basename $toolPath .js)" \
--add-flags "$toolPath"
done
'';
# other metadata generated and inherited from ./node-package.nix
meta.maintainers = with stdenv.lib.maintainers; [ pacien ];
# don't generate the dist tarball
# (`doDist = false` does not work in mkYarnPackage)
distPhase = ''
true
'';
passthru = {
nodeAppDir = "libexec/${pname}/deps/${pname}";
};
meta = {
description = "A 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;
};
}

View file

@ -1,10 +1,17 @@
##!/usr/bin/env nix-shell
##! nix-shell -i bash -p nodePackages.node2nix
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../ -i bash -p wget yarn2nix
node2nix \
--nodejs-12 \
--node-env ../../development/node-packages/node-env.nix \
--development \
--input package.json \
--output node-packages.nix \
--composition node-composition.nix
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,17 +0,0 @@
# This file has been generated by node2nix 1.8.0. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
let
nodeEnv = import ../../development/node-packages/node-env.nix {
inherit (pkgs) stdenv python2 util-linux runCommand writeTextFile;
inherit nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv;
}

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,77 @@
[
{ "matrix-appservice-discord": "git+https://github.com/Half-Shot/matrix-appservice-discord.git#v0.5.2" }
]
{
"name": "matrix-appservice-discord",
"version": "1.0.0",
"description": "A bridge between Matrix and Discord",
"main": "discordas.js",
"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",
"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",
"addbot": "node ./build/tools/addbot.js",
"adminme": "node ./build/tools/adminme.js",
"usertool": "node ./build/tools/userClientTools.js",
"directoryfix": "node ./build/tools/addRoomsToDirectory.js",
"ghostfix": "node ./build/tools/ghostfix.js",
"chanfix": "node ./build/tools/chanfix.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Half-Shot/matrix-appservice-discord.git"
},
"keywords": [
"matrix",
"discord",
"bridge",
"application-service",
"as"
],
"author": "Half-Shot",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Half-Shot/matrix-appservice-discord/issues"
},
"homepage": "https://github.com/Half-Shot/matrix-appservice-discord#readme",
"dependencies": {
"better-discord.js": "git://github.com/Sorunome/better-discord.js.git#b5a28499899fe2d9e6aa1aa3b3c5d693ae672117",
"better-sqlite3": "^7.1.0",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"escape-html": "^1.0.3",
"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",
"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",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^4.5.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.11",
"@types/command-line-args": "^5.0.0",
"@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",
"chai": "^4.2.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",
"why-is-node-running": "^2.2.0"
}
}

File diff suppressed because it is too large Load diff