let
  pkgs = import <nixpkgs> {};

  srcNatPMP = pkgs.fetchgit {
    url = "https://code.google.com/p/go-nat-pmp/";
    rev = "e04deda90d56";
    sha256 = "1swwfyzaj3l40yh9np3x4fcracgs79nwryc85sxbdakx8wwxs2xb";
  };
in
with pkgs;
stdenv.mkDerivation {
  name = "filegive-dev";

  src = ./.;

  buildInputs = [ go ];

  buildPhase = ''
    mkdir $TMPDIR/go
    export GOPATH=$TMPDIR/go

    GONATPMP=$GOPATH/src/code.google.com/p/go-nat-pmp
    mkdir -p $GONATPMP
    cp -R ${srcNatPMP}/* $GONATPMP/
    go build -o filegive
  '';

  installPhase = ''
    ensureDir $out/bin
    cp filegive $out/bin
  '';
}
