matrix-appservice-irc: convert to buildNpmPackage

This commit is contained in:
Martin Weinelt 2022-12-03 20:09:00 +01:00
parent 94306da1a4
commit ad293fba9e
7 changed files with 21 additions and 7119 deletions

View file

@ -1,44 +1,38 @@
{ pkgs, nodePackages, makeWrapper, nixosTests, nodejs, stdenv, lib, fetchFromGitHub, fetchurl, autoPatchelfHook, matrix-sdk-crypto-nodejs }:
{ lib
, buildNpmPackage
, fetchFromGitHub
, python3
, matrix-sdk-crypto-nodejs
, nixosTests
, nix-update-script
}:
let
ourNodePackages = import ./node-composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
};
version = (lib.importJSON ./package.json).version;
srcInfo = lib.importJSON ./src.json;
in
ourNodePackages.package.override {
buildNpmPackage rec {
pname = "matrix-appservice-irc";
inherit version;
version = "0.36.0";
src = fetchFromGitHub {
owner = "matrix-org";
repo = "matrix-appservice-irc";
rev = version;
inherit (srcInfo) sha256;
rev = "refs/tags/${version}";
hash = "sha256-8/jLONqf+0JRAK/SLj3qlG6Dm0VRl4h6YWeZnz4pVXc=";
};
nativeBuildInputs = [ autoPatchelfHook makeWrapper nodePackages.node-gyp-build ];
npmDepsHash = "sha256-fGft7au5js9DRoXYccBPdJyaZ3zfsuCwUwWPOxwAodo=";
dontAutoPatchelf = true;
postRebuild = ''
npm run build
'';
nativeBuildInputs = [
python3
];
postInstall = ''
# Compile typescript
npm run build
makeWrapper '${nodejs}/bin/node' "$out/bin/matrix-appservice-irc" \
--add-flags "$out/lib/node_modules/matrix-appservice-irc/app.js"
cp -rv ${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs $out/lib/node_modules/matrix-appservice-irc/node_modules/@matrix-org/
rm -rv $out/lib/node_modules/matrix-appservice-irc/node_modules/@matrix-org/matrix-sdk-crypto-nodejs
ln -sv ${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs $out/lib/node_modules/matrix-appservice-irc/node_modules/@matrix-org/
'';
passthru.tests.matrix-appservice-irc = nixosTests.matrix-appservice-irc;
passthru.updateScript = ./update.sh;
passthru.updateScript = nix-update-script {
attrPath = pname;
};
meta = with lib; {
description = "Node.js IRC bridge for Matrix";

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../..)"
$(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
--nodejs-18 \
--node-env ../../../development/node-packages/node-env.nix \
--development \
--lock ./package-lock-temp.json \
--output node-packages.nix \
--composition node-composition.nix

View file

@ -1,17 +0,0 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-18_x"}:
let
nodeEnv = import ../../../development/node-packages/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}

File diff suppressed because it is too large Load diff

View file

@ -1,73 +0,0 @@
{
"name": "matrix-appservice-irc",
"version": "0.36.0",
"description": "An IRC Bridge for Matrix",
"main": "app.js",
"bin": "./bin/matrix-appservice-irc",
"engines": {
"node": ">=16"
},
"scripts": {
"prepare": "npm run build",
"build": "tsc --project ./tsconfig.json",
"test": "BLUEBIRD_DEBUG=1 jasmine --stop-on-failure=true",
"test:e2e": "jest --config spec/e2e/jest.config.js --forceExit # Can be removed after https://github.com/matrix-org/matrix-appservice-bridge/pull/439 is merged",
"lint": "eslint -c .eslintrc --max-warnings 0 'spec/**/*.js' 'src/**/*.ts'",
"check": "npm test && npm run lint",
"ci-test": "nyc --report text jasmine",
"ci": "npm run lint && npm run ci-test"
},
"repository": {
"type": "git",
"url": "https://github.com/matrix-org/matrix-appservice-irc.git"
},
"author": "",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/matrix-org/matrix-appservice-irc/issues"
},
"dependencies": {
"@sentry/node": "^6.17.9",
"bluebird": "^3.7.2",
"cross-fetch": "^3.1.5",
"diff": "^5.1.0",
"escape-string-regexp": "^4.0.0",
"extend": "^3.0.2",
"he": "^1.2.0",
"logform": "^2.4.2",
"matrix-appservice-bridge": "^6.0.0",
"matrix-bot-sdk": "^0.6.2",
"matrix-org-irc": "^1.5.0",
"nopt": "^6.0.0",
"p-queue": "^6.6.2",
"pg": "^8.8.0",
"quick-lru": "^5.1.1",
"sanitize-html": "^2.7.2",
"winston": "^3.8.2",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.3",
"@types/bluebird": "^3.5.36",
"@types/diff": "^5.0.2",
"@types/express": "4.17.14",
"@types/express-serve-static-core": "4.17.31",
"@types/extend": "^3.0.1",
"@types/he": "^1.1.2",
"@types/nedb": "^1.8.12",
"@types/node": "^16",
"@types/nopt": "^3.0.29",
"@types/pg": "^8.6.5",
"@types/sanitize-html": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"eslint": "^8.24.0",
"homerunner-client": "^0.0.6",
"jasmine": "^3.99.0",
"jest": "^29.1.1",
"nyc": "^15.1.0",
"proxyquire": "^2.1.3",
"ts-jest": "^29.0.2",
"typescript": "^4.8.3"
}
}

View file

@ -1,11 +0,0 @@
{
"url": "https://github.com/matrix-org/matrix-appservice-irc",
"rev": "89e44e482a918476059f543d242118abf4d0fb3d",
"date": "2022-10-25T09:47:56+01:00",
"path": "/nix/store/y7x302d9lq4cbq7fczrqk6c9g54xywvr-matrix-appservice-irc",
"sha256": "0xsm54z9z6b7c5x8i5si8ndq6vllx8yjxlmg018l5ywzv8wcpy7k",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}

View file

@ -1,26 +0,0 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix curl jq nix nix-prefetch-git
set -euo pipefail
# cd to the folder containing this script
cd "$(dirname "$0")"
CURRENT_VERSION=$(nix-instantiate ../../../../. --eval --strict -A matrix-appservice-irc.version | tr -d '"')
TARGET_VERSION="$(curl https://api.github.com/repos/matrix-org/matrix-appservice-irc/releases/latest | jq --exit-status -r ".tag_name")"
if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then
echo "matrix-appservice-irc is up-to-date: ${CURRENT_VERSION}"
exit 0
fi
echo "matrix-appservice-irc: $CURRENT_VERSION -> $TARGET_VERSION"
rm -f package.json package-lock.json
wget https://github.com/matrix-org/matrix-appservice-irc/raw/$TARGET_VERSION/package.json
wget -O package-lock-temp.json https://github.com/matrix-org/matrix-appservice-irc/raw/$TARGET_VERSION/package-lock.json
./generate-dependencies.sh
rm ./package-lock-temp.json
nix-prefetch-git --rev "$TARGET_VERSION" --url "https://github.com/matrix-org/matrix-appservice-irc" > ./src.json