stockholm/krebs/5pkgs/simple/go-shortener/default.nix

57 lines
1.2 KiB
Nix
Raw Normal View History

2018-04-05 14:36:12 +00:00
{ stdenv, makeWrapper, lib, buildEnv, fetchgit, nodejs-8_x, pkgs }:
2015-10-08 23:06:22 +00:00
with lib;
let
2018-04-05 14:36:12 +00:00
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;
2015-10-08 23:06:22 +00:00
};
2018-04-05 14:36:12 +00:00
node_env = pkgs.buildEnv {
name = "go-node_env";
paths = attrValues (import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv;
});
2015-10-08 23:06:22 +00:00
};
2018-04-05 14:36:12 +00:00
in stdenv.mkDerivation {
packageName = "go";
2016-10-27 12:47:21 +00:00
name = "go-shortener";
2018-04-05 14:36:12 +00:00
version = "0.0.0";
2015-10-08 23:06:22 +00:00
src = fetchgit {
2016-07-01 10:04:16 +00:00
url = "http://cgit.lassul.us/go/";
2015-10-08 23:06:22 +00:00
rev = "05d02740e0adbb36cc461323647f0c1e7f493156";
sha256 = "6015c9a93317375ae8099c7ab982df0aa93a59ec2b48972e253887bb6ca0004f";
};
phases = [
"unpackPhase"
"installPhase"
];
buildInputs = [
2018-04-05 14:36:12 +00:00
nodejs-8_x
2015-10-08 23:06:22 +00:00
makeWrapper
];
installPhase = ''
mkdir -p $out/bin
cp index.js $out/
cat > $out/go << EOF
2018-04-05 14:36:12 +00:00
${nodejs-8_x}/bin/node $out/index.js
2015-10-08 23:06:22 +00:00
EOF
chmod +x $out/go
wrapProgram $out/go \
--prefix NODE_PATH : ${node_env}/lib/node_modules
2018-04-05 14:36:12 +00:00
ln -s $out/go /$out/bin/go
2015-10-08 23:06:22 +00:00
'';
}