summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/newsbot-js/default.nix
blob: cc362b86aa07244cc0a7a6e54dc03132645b1761 (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
{ stdenv, makeWrapper, lib, buildEnv, fetchgit, nodejs-8_x, pkgs, icu }:

with lib;

let
  nodeEnv = import <nixpkgs/pkgs/development/node-packages/node-env.nix> {
    inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
    nodejs = nodejs-8_x;
    libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
  };

  node_env = pkgs.buildEnv {
    name = "go-node_env";
    paths = attrValues (import ./node-packages.nix {
      inherit (pkgs) fetchurl fetchgit;
      inherit nodeEnv;
      globalBuildInputs = [
        icu.dev
      ];
    });
  };


in stdenv.mkDerivation {
  name = "newsbot-js";

  src = fetchgit {
    url = "http://cgit.prism/newsbot-js/";
    rev = "09e01639be4ea9691cf5b33f7d9057b68ac98079";
    sha256 = "28ffbed66c2efcd194c47823c7d5d5533c80852fc0cf9d9d4ee609c71d50c142";
  };

  phases = [
    "unpackPhase"
    "installPhase"
  ];

  buildInputs = [
    nodejs-8_x
    makeWrapper
  ];

  installPhase = ''
    mkdir -p $out/bin

    cp newsbot.js $out/
    cat > $out/newsbot << EOF
      ${nodejs-8_x}/bin/node $out/newsbot.js
    EOF
    chmod +x $out/newsbot

    wrapProgram $out/newsbot \
      --prefix NODE_PATH : ${node_env}/lib/node_modules

     ln -s $out/newsbot /$out/bin/newsbot
  '';

}