Skip to content

Commit

Permalink
mx-puppet-discord: update to 0.1.1 and fix for node2nix npmv7 update
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyinstarlight authored and Yt committed Sep 28, 2022
1 parent e70290e commit 1f067ee
Show file tree
Hide file tree
Showing 4 changed files with 1,170 additions and 1,116 deletions.
38 changes: 19 additions & 19 deletions pkgs/servers/mx-puppet-discord/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{ stdenv, fetchFromGitHub, pkgs, lib, nodejs-14_x, nodePackages, pkg-config, libjpeg
, pixman, cairo, pango }:
{ stdenv, fetchFromGitLab, pkgs, lib, nodejs-14_x, pkg-config
, libjpeg, pixman, cairo, pango, which, postgresql }:

let
nodejs = nodejs-14_x;
# No official version ever released
src = fetchFromGitHub {
owner = "matrix-discord";

version = "0.1.1";

src = fetchFromGitLab {
group = "mx-puppet";
owner = "discord";
repo = "mx-puppet-discord";
rev = "bb6438a504182a7a64048b992179427587ccfded";
sha256 = "0g2p5xwxxgvlnq0fg0x4q9x4asqyppdv6b5z6bvncm62kc70z6xk";
rev = "v${version}";
hash = "sha256-ZhyjUt6Bz/0R4+Lq/IoY9rNjdwVE2qp4ZQLc684+T/0=";
};

myNodePackages = import ./node-composition.nix {
Expand All @@ -17,33 +20,30 @@ let
};

in myNodePackages.package.override {
pname = "mx-puppet-discord";
version = "2021-08-01";

inherit src;
inherit version src;

nativeBuildInputs = [ nodePackages.node-pre-gyp pkg-config ];
buildInputs = [ libjpeg pixman cairo pango ];
nativeBuildInputs = [ nodejs.pkgs.node-pre-gyp nodejs.pkgs.node-gyp-build pkg-config which ];
buildInputs = [ libjpeg pixman cairo pango postgresql ];

postInstall = ''
# Patch shebangs in node_modules, otherwise the webpack build fails with interpreter problems
patchShebangs --build "$out/lib/node_modules/mx-puppet-discord/node_modules/"
# compile Typescript sources
postRebuild = ''
# Build typescript stuff
npm run build
'';

postInstall = ''
# Make an executable to run the server
mkdir -p $out/bin
cat <<EOF > $out/bin/mx-puppet-discord
#!/bin/sh
exec ${nodejs}/bin/node $out/lib/node_modules/mx-puppet-discord/build/index.js "\$@"
exec ${nodejs}/bin/node $out/lib/node_modules/@mx-puppet/discord/build/index.js "\$@"
EOF
chmod +x $out/bin/mx-puppet-discord
'';

meta = with lib; {
description = "A discord puppeting bridge for matrix";
license = licenses.asl20;
homepage = "https://github.com/matrix-discord/mx-puppet-discord";
homepage = "https://gitlab.com/mx-puppet/discord/mx-puppet-discord";
maintainers = with maintainers; [ expipiplus1 ];
platforms = platforms.unix;
};
Expand Down
22 changes: 12 additions & 10 deletions pkgs/servers/mx-puppet-discord/generate.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix

# No official release
rev=bb6438a504182a7a64048b992179427587ccfded
u=https://raw.githubusercontent.com/matrix-discord/mx-puppet-discord/$rev
# Download package.json and package-lock.json
curl -O $u/package.json
curl $u/package-lock.json |
sed -e 's|git+ssh://git@|git+https://|g' > package-lock.json
tag="v0.1.1"
u="https://gitlab.com/mx-puppet/discord/mx-puppet-discord/-/raw/$tag"
# Download package.json and patch in @discordjs/opus optional dependency
curl $u/package.json |
sed 's|"typescript": *"\^\?3\.[^"]*"|"typescript": "^4.8.3"|' | # TODO: remove when newer typescript version pinned
sed 's|\("dependencies": *{\)|\1\n"@discordjs/opus": "^0.8.0",|' >package.json

node2nix \
--nodejs-14 \
--node-env ../../development/node-packages/node-env.nix \
--input package.json \
--lock package-lock.json \
--strip-optional-dependencies \
--output node-packages.nix \
--composition node-composition.nix
--composition node-composition.nix \
--registry https://registry.npmjs.org \
--registry https://gitlab.com/api/v4/packages/npm \
--registry-scope '@mx-puppet'

sed -i 's|<nixpkgs>|../../..|' node-composition.nix

rm -f package.json package-lock.json
rm -f package.json
2 changes: 1 addition & 1 deletion pkgs/servers/mx-puppet-discord/node-composition.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file has been generated by node2nix 1.9.0. Do not edit!
# This file has been generated by node2nix 1.11.1. Do not edit!

{pkgs ? import ../../.. {
inherit system;
Expand Down
Loading

0 comments on commit 1f067ee

Please sign in to comment.