1{ stdenv, fetchFromGitLab, pkgs, lib, nodejs_14, pkg-config
2, libjpeg, pixman, cairo, pango, which, postgresql }:
3
4let
5 nodejs = nodejs_14;
6
7 version = "0.1.1";
8
9 src = fetchFromGitLab {
10 group = "mx-puppet";
11 owner = "discord";
12 repo = "mx-puppet-discord";
13 rev = "v${version}";
14 hash = "sha256-ZhyjUt6Bz/0R4+Lq/IoY9rNjdwVE2qp4ZQLc684+T/0=";
15 };
16
17 myNodePackages = import ./node-composition.nix {
18 inherit pkgs nodejs;
19 inherit (stdenv.hostPlatform) system;
20 };
21
22in myNodePackages.package.override {
23 inherit version src;
24
25 nativeBuildInputs = [ nodejs.pkgs.node-pre-gyp nodejs.pkgs.node-gyp-build pkg-config which ];
26 buildInputs = [ libjpeg pixman cairo pango postgresql ];
27
28 postRebuild = ''
29 # Build typescript stuff
30 npm run build
31 '';
32
33 postInstall = ''
34 # Make an executable to run the server
35 mkdir -p $out/bin
36 cat <<EOF > $out/bin/mx-puppet-discord
37 #!/bin/sh
38 exec ${nodejs}/bin/node $out/lib/node_modules/@mx-puppet/discord/build/index.js "\$@"
39 EOF
40 chmod +x $out/bin/mx-puppet-discord
41 '';
42
43 meta = with lib; {
44 description = "A discord puppeting bridge for matrix";
45 license = licenses.asl20;
46 homepage = "https://gitlab.com/mx-puppet/discord/mx-puppet-discord";
47 maintainers = with maintainers; [ expipiplus1 ];
48 platforms = platforms.unix;
49 # never built on aarch64-darwin since first introduction in nixpkgs
50 broken = stdenv.isDarwin && stdenv.isAarch64;
51 };
52}