mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
matrix-alertmanager: use buildNpmPackage
This commit is contained in:
parent
d20d5f590d
commit
6e63767f99
@ -1,6 +1,10 @@
|
||||
{ lib, callPackage, mkYarnPackage, fetchYarnDeps, fetchFromGitHub, nodejs }:
|
||||
{ lib
|
||||
, buildNpmPackage
|
||||
, fetchFromGitHub
|
||||
, jq
|
||||
}:
|
||||
|
||||
mkYarnPackage rec {
|
||||
buildNpmPackage rec {
|
||||
pname = "matrix-alertmanager";
|
||||
version = "0.5.0";
|
||||
|
||||
@ -11,29 +15,19 @@ mkYarnPackage rec {
|
||||
sha256 = "M3/8viRCRiVJGJSHidP6nG8cr8wOl9hMFY/gzdSRN+4=";
|
||||
};
|
||||
|
||||
packageJSON = ./package.json;
|
||||
yarnLock = ./yarn.lock;
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
inherit yarnLock;
|
||||
sha256 = lib.fileContents ./yarn-hash;
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
cp ${./package.json} ./package.json
|
||||
'';
|
||||
postInstall = ''
|
||||
sed '1 s;^;#!${nodejs}/bin/node\n;' -i $out/libexec/matrix-alertmanager/node_modules/matrix-alertmanager/src/app.js
|
||||
chmod +x $out/libexec/matrix-alertmanager/node_modules/matrix-alertmanager/src/app.js
|
||||
postPatch = ''
|
||||
${lib.getExe jq} '. += {"bin": "src/app.js"}' package.json > package.json.tmp
|
||||
mv package.json.tmp package.json
|
||||
'';
|
||||
|
||||
passthru.updateScript = callPackage ./update.nix {};
|
||||
npmDepsHash = "sha256-hR9Q/8sLxSf916BARBgTKmwonv5JqSSkfvOfYL9SdeU=";
|
||||
|
||||
dontNpmBuild = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Bot to receive Alertmanager webhook events and forward them to chosen rooms";
|
||||
homepage = "https://github.com/jaywink/matrix-alertmanager";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ yuka ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
{
|
||||
"name": "matrix-alertmanager",
|
||||
"version": "0.5.0",
|
||||
"description": "Prometheus Alertmanager bot for Matrix",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
"dev": "node_modules/.bin/nodemon src/app.js localhost 3000",
|
||||
"test": "node_modules/.bin/mocha tests/",
|
||||
"start": "node src/app.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jaywink/matrix-alertmanager"
|
||||
},
|
||||
"keywords": [
|
||||
"matrix",
|
||||
"alertmanager",
|
||||
"prometheus",
|
||||
"bot"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"author": "Jason Robinson",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.1",
|
||||
"nodemon": "^2.0.12",
|
||||
"npm-check-updates": "^11.8.5",
|
||||
"sinon": "^11.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"matrix-js-sdk": "^12.5.0",
|
||||
"striptags": "^3.2.0"
|
||||
},
|
||||
"bin": "src/app.js"
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
{ lib, writeShellScript
|
||||
, coreutils, jq, common-updater-scripts
|
||||
, curl, wget, gnugrep, yarn, prefetch-yarn-deps
|
||||
}:
|
||||
|
||||
writeShellScript "update-matrix-alertmanager" ''
|
||||
set -xe
|
||||
export PATH="${lib.makeBinPath [ gnugrep coreutils curl wget jq common-updater-scripts yarn prefetch-yarn-deps ]}"
|
||||
|
||||
cd pkgs/servers/monitoring/matrix-alertmanager/
|
||||
|
||||
owner="jaywink"
|
||||
repo="matrix-alertmanager"
|
||||
version=`curl -s "https://api.github.com/repos/$owner/$repo/tags" | jq -r .[0].name | grep -oP "^v\K.*"`
|
||||
url="https://raw.githubusercontent.com/$owner/$repo/v$version/"
|
||||
|
||||
(
|
||||
cd ../../../..
|
||||
update-source-version matrix-alertmanager "$version" --file=pkgs/servers/monitoring/matrix-alertmanager/default.nix
|
||||
)
|
||||
|
||||
rm -f package.json package-lock.json yarn.lock
|
||||
wget "$url/package.json" "$url/package-lock.json"
|
||||
|
||||
yarn import
|
||||
echo $(prefetch-yarn-deps) > yarn-hash
|
||||
|
||||
jq '. + { bin: .main }' package.json > package.json.tmp
|
||||
mv package.json{.tmp,}
|
||||
|
||||
rm -rf package-lock.json node_modules
|
||||
''
|
@ -1 +0,0 @@
|
||||
03a217ppbscz4fqc10c829p5frbs7j9qli5126cibz2b3pk2mi66
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user