summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Weinelt <mweinelt@users.noreply.github.com>2023-07-31 13:38:09 +0200
committerGitHub <noreply@github.com>2023-07-31 13:38:09 +0200
commit0d117d7ad5d590991d23ccc7bd88c4e627cccf17 (patch)
tree32d85709b0318649a702a75d719ae0611118bfeb
parentfirefox-unwrapped: 115.0.2 -> 115.0.3 (#246324) (diff)
parentmatrix-appservice-irc: 0.38.0 -> 1.0.1 (diff)
downloadnixpkgs-0d117d7ad5d590991d23ccc7bd88c4e627cccf17.tar.gz
Merge pull request #246188 from gdamjan/bump-matrix-appservice-irc-2
matrix-appservice-irc: 0.38.0 -> 1.0.1
-rw-r--r--nixos/modules/services/matrix/appservice-irc.nix6
-rw-r--r--pkgs/servers/matrix-synapse/matrix-appservice-irc/default.nix69
2 files changed, 60 insertions, 15 deletions
diff --git a/nixos/modules/services/matrix/appservice-irc.nix b/nixos/modules/services/matrix/appservice-irc.nix
index 8883d604b2ea..d153ffc2ace8 100644
--- a/nixos/modules/services/matrix/appservice-irc.nix
+++ b/nixos/modules/services/matrix/appservice-irc.nix
@@ -12,16 +12,14 @@ let
configFile = pkgs.runCommand "matrix-appservice-irc.yml" {
# Because this program will be run at build time, we need `nativeBuildInputs`
- nativeBuildInputs = [ (pkgs.python3.withPackages (ps: [ ps.pyyaml ps.jsonschema ])) ];
+ nativeBuildInputs = [ (pkgs.python3.withPackages (ps: [ ps.jsonschema ])) pkgs.remarshal ];
preferLocalBuild = true;
config = builtins.toJSON cfg.settings;
passAsFile = [ "config" ];
} ''
# The schema is given as yaml, we need to convert it to json
- python -c 'import json; import yaml; import sys; json.dump(yaml.safe_load(sys.stdin), sys.stdout)' \
- < ${pkg}/lib/node_modules/matrix-appservice-irc/config.schema.yml \
- > config.schema.json
+ remarshal --if yaml --of json -i ${pkg}/config.schema.yml -o config.schema.json
python -m jsonschema config.schema.json -i $configPath
cp "$configPath" "$out"
'';
diff --git a/pkgs/servers/matrix-synapse/matrix-appservice-irc/default.nix b/pkgs/servers/matrix-synapse/matrix-appservice-irc/default.nix
index 69696cbf9195..a00104215453 100644
--- a/pkgs/servers/matrix-synapse/matrix-appservice-irc/default.nix
+++ b/pkgs/servers/matrix-synapse/matrix-appservice-irc/default.nix
@@ -1,32 +1,79 @@
{ lib
-, buildNpmPackage
+, stdenv
, fetchFromGitHub
-, python3
+, fetchYarnDeps
+, prefetch-yarn-deps
+, nodejs
+, nodejs-slim
, matrix-sdk-crypto-nodejs
, nixosTests
, nix-update-script
}:
-buildNpmPackage rec {
+let
pname = "matrix-appservice-irc";
- version = "0.38.0";
+ version = "1.0.1";
src = fetchFromGitHub {
owner = "matrix-org";
- repo = "matrix-appservice-irc";
+ repo = pname;
rev = "refs/tags/${version}";
- hash = "sha256-rV4B9OQl1Ht26X4e7sqCe1PR5RpzIcjj4OvWG6udJWo=";
+ hash = "sha256-wUbWvCa9xvot73nXZjF3/RawM98ffBCW5YR2+ZKzmEo=";
};
- npmDepsHash = "sha256-iZuPr3a1BPtRfkEoxOs4oRL/nCfy3PLx5T9dX49/B0s=";
+ yarnOfflineCache = fetchYarnDeps {
+ name = "${pname}-${version}-offline-cache";
+ yarnLock = "${src}/yarn.lock";
+ hash = "sha256-P9u5sK9rIHWRE8kFMj05fVjv26jwsawvHBZgSn7j5BE=";
+ };
+
+in
+stdenv.mkDerivation {
+ inherit pname version src yarnOfflineCache;
nativeBuildInputs = [
- python3
+ prefetch-yarn-deps
+ nodejs-slim
+ nodejs.pkgs.yarn
+ nodejs.pkgs.node-gyp-build
];
- postInstall = ''
- 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/
+ configurePhase = ''
+ runHook preConfigure
+
+ export HOME=$(mktemp -d)
+ yarn config --offline set yarn-offline-mirror "$yarnOfflineCache"
+ fixup-yarn-lock yarn.lock
+ yarn install --frozen-lockfile --offline --no-progress --non-interactive --ignore-scripts
+ patchShebangs node_modules/ bin/
+
+ runHook postConfigure
+ '';
+
+ buildPhase = ''
+ runHook preBuild
+
+ yarn --offline build
+
+ runHook postBuild
+ '';
+
+ installPhase = ''
+ runHook preInstall
+
+ mkdir $out
+ cp app.js config.schema.yml $out
+ cp -r bin lib public $out
+
+ # prune dependencies to production only
+ yarn install --frozen-lockfile --offline --no-progress --non-interactive --ignore-scripts --production
+ cp -r node_modules $out
+
+ # replace matrix-sdk-crypto-nodejs with nixos package
+ rm -rv $out/node_modules/@matrix-org/matrix-sdk-crypto-nodejs
+ ln -sv ${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs $out/node_modules/@matrix-org/
+
+ runHook postInstall
'';
passthru.tests.matrix-appservice-irc = nixosTests.matrix-appservice-irc;