summaryrefslogtreecommitdiff
path: root/pkgs/mx-puppet-slack/default.nix
blob: ddc4ef242dc3ba4d1c75292f6d310ed452b0d787 (plain)
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
53
54
55
56
57
58
59
{ stdenv
, fetchFromGitHub
, pkgs
, lib
, nodejs
, nodePackages
, pkg-config
, libjpeg
, pixman
, cairo
, pango
}:

let
  # No official version ever released
  src = fetchFromGitHub {
    owner = "Sorunome";
    repo = pname;
    rev = "691e53d2d703bd169e1f23a8d8dff3f008d8c4ef";
    sha256 = "sha256-cjRmlVCk6jX+CCQiAc/dcormPLe/BafBJeRHCv6Mu1k=";
  };

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

  pname = "mx-puppet-slack";

in
myNodePackages.package.override {

  inherit src;

  nativeBuildInputs = [ nodePackages.node-pre-gyp pkg-config ];
  buildInputs = [ libjpeg pixman cairo pango ];

  postInstall = ''
    # Patch shebangs in node_modules, otherwise the webpack build fails with interpreter problems
    patchShebangs --build "$out/lib/node_modules/${pname}/node_modules/"
    # compile Typescript sources
    npm run build
    # Make an executable to run the server
    mkdir -p $out/bin
    cat <<EOF > $out/bin/${pname}
    #!/bin/sh
    exec ${nodejs}/bin/node $out/lib/node_modules/${pname}/build/index.js "\$@"
    EOF
    chmod +x $out/bin/${pname}
  '';

  meta = with lib; {
    description = "A slack puppeting bridge for matrix";
    license = licenses.asl20;
    homepage = "https://github.com/Sorunome/mx-puppet-slack";
    maintainers = with maintainers; [ pacman99 ];
    platforms = platforms.unix;
  };
}