Port syncthing to buildGoPackage

This commit is contained in:
Luca Bruno 2015-02-05 13:12:10 +01:00
parent d1b3874733
commit e6e4c867e5
2 changed files with 14 additions and 24 deletions

View File

@ -1,40 +1,30 @@
{ stdenv, fetchgit, go }:
{ lib, fetchgit, goPackages }:
stdenv.mkDerivation rec {
with goPackages;
buildGoPackage rec {
name = "syncthing-${version}";
version = "0.10.21";
goPackagePath = "github.com/syncthing/syncthing";
src = fetchgit {
url = "git://github.com/syncthing/syncthing.git";
rev = "refs/tags/v${version}";
sha256 = "60cd8607cf7d2837252680f6c2879aba1f35a2c74a47c2f2ea874d6eed2adaa5";
};
buildInputs = [ go ];
subPackages = [ "cmd/syncthing" ];
buildPhase = ''
mkdir -p "./dependencies/src/github.com/syncthing/syncthing"
cp -r internal "./dependencies/src/github.com/syncthing/syncthing"
buildFlagsArray = "-ldflags=-w -X main.Version v${version}";
export GOPATH="`pwd`/Godeps/_workspace:`pwd`/dependencies"
preBuild = "export GOPATH=$GOPATH:$NIX_BUILD_TOP/go/src/${goPackagePath}/Godeps/_workspace";
go run build.go test
mkdir ./bin
go build -o ./bin/syncthing -ldflags "-w -X main.Version v${version}" ./cmd/syncthing
'';
installPhase = ''
mkdir -p $out/bin
cp -r ./bin $out
'';
doCheck = true;
meta = {
homepage = http://syncthing.net/;
description = "Replaces Dropbox and BitTorrent Sync with something open, trustworthy and decentralized";
license = with stdenv.lib.licenses; mit;
maintainers = with stdenv.lib.maintainers; [ matejc ];
platforms = with stdenv.lib.platforms; linux;
license = with lib.licenses; mit;
maintainers = with lib.maintainers; [ matejc ];
platforms = with lib.platforms; linux;
};
}

View File

@ -28,12 +28,12 @@ go.stdenv.mkDerivation ( args // {
if [ -n "$subPackages" ] ; then
for p in $subPackages ; do
go install $makeFlags -p $NIX_BUILD_CORES -v $goPackagePath/$p
go install $buildFlags "''${buildFlagsArray[@]}" -p $NIX_BUILD_CORES -v $goPackagePath/$p
done
else
find . -type d | while read d; do
for i in $d/*.go; do
go install $makeFlags -p $NIX_BUILD_CORES -v $d
go install $buildFlags "''${buildFlagsArray[@]}" -p $NIX_BUILD_CORES -v $d
break
done
done