stockholm/krebs/5pkgs/simple/newsbot-js/default.nix

59 lines
1.2 KiB
Nix
Raw Normal View History

2019-10-10 08:48:17 +00:00
{ stdenv, makeWrapper, lib, buildEnv, fetchgit, nodejs-12_x, pkgs, icu }:
2015-10-09 11:55:41 +00:00
with lib;
let
2018-04-05 15:25:50 +00:00
nodeEnv = import <nixpkgs/pkgs/development/node-packages/node-env.nix> {
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
2019-10-10 08:48:17 +00:00
nodejs = nodejs-12_x;
2018-04-05 15:25:50 +00:00
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
2015-10-09 11:55:41 +00:00
};
2018-04-05 15:25:50 +00:00
node_env = pkgs.buildEnv {
name = "go-node_env";
paths = attrValues (import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv;
globalBuildInputs = [
icu.dev
];
});
2015-10-09 11:55:41 +00:00
};
2018-04-05 15:25:50 +00:00
in stdenv.mkDerivation {
2015-10-09 11:55:41 +00:00
name = "newsbot-js";
src = fetchgit {
url = "http://cgit.prism/newsbot-js/";
rev = "09e01639be4ea9691cf5b33f7d9057b68ac98079";
sha256 = "28ffbed66c2efcd194c47823c7d5d5533c80852fc0cf9d9d4ee609c71d50c142";
2015-10-09 11:55:41 +00:00
};
phases = [
"unpackPhase"
"installPhase"
];
buildInputs = [
2019-10-10 08:48:17 +00:00
nodejs-12_x
2015-10-09 11:55:41 +00:00
makeWrapper
];
installPhase = ''
mkdir -p $out/bin
cp newsbot.js $out/
cat > $out/newsbot << EOF
2019-10-10 08:48:17 +00:00
${nodejs-12_x}/bin/node $out/newsbot.js
2015-10-09 11:55:41 +00:00
EOF
chmod +x $out/newsbot
wrapProgram $out/newsbot \
--prefix NODE_PATH : ${node_env}/lib/node_modules
ln -s $out/newsbot /$out/bin/newsbot
'';
}