summary refs log tree commit diff
path: root/pkgs/servers/mx-puppet-discord/default.nix
blob: be32bda9935424d0bb1835a311c691809c42806e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ stdenv, fetchFromGitLab, pkgs, lib, nodejs_14, pkg-config
, libjpeg, pixman, cairo, pango, which, postgresql }:

let
  nodejs = nodejs_14;

  version = "0.1.1";

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

  myNodePackages = import ./node-composition.nix {
    inherit pkgs nodejs;
    inherit (stdenv.hostPlatform) system;
  };

in myNodePackages.package.override {
  inherit version src;

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

  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 "\$@"
    EOF
    chmod +x $out/bin/mx-puppet-discord
  '';

  meta = with lib; {
    description = "A discord puppeting bridge for matrix";
    license = licenses.asl20;
    homepage = "https://gitlab.com/mx-puppet/discord/mx-puppet-discord";
    maintainers = with maintainers; [ expipiplus1 ];
    platforms = platforms.unix;
    # never built on aarch64-darwin since first introduction in nixpkgs
    broken = stdenv.isDarwin && stdenv.isAarch64;
  };
}