2013-03-19 10:46:47 +00:00
|
|
|
{ stdenv, fetchurl, bison, glibc, bash, coreutils, makeWrapper, tzdata}:
|
2009-11-14 20:14:28 +00:00
|
|
|
|
|
|
|
let
|
2010-06-12 12:21:20 +01:00
|
|
|
loader386 = "${glibc}/lib/ld-linux.so.2";
|
|
|
|
loaderAmd64 = "${glibc}/lib/ld-linux-x86-64.so.2";
|
2012-08-24 15:00:18 +01:00
|
|
|
loaderArm = "${glibc}/lib/ld-linux.so.3";
|
2009-11-14 20:14:28 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2012-10-09 16:01:55 +01:00
|
|
|
name = "go-1.0.3";
|
2009-11-14 20:14:28 +00:00
|
|
|
|
2012-07-29 16:24:19 +01:00
|
|
|
src = fetchurl {
|
2012-10-09 16:01:55 +01:00
|
|
|
url = http://go.googlecode.com/files/go1.0.3.src.tar.gz;
|
|
|
|
sha256 = "1pz31az3icwqfqfy3avms05jnqr0qrbrx9yqsclkdwbjs4rkbfkz";
|
2009-11-14 20:14:28 +00:00
|
|
|
};
|
|
|
|
|
2012-07-29 16:24:19 +01:00
|
|
|
buildInputs = [ bison glibc bash makeWrapper ];
|
|
|
|
|
|
|
|
# I'm not sure what go wants from its 'src', but the go installation manual
|
|
|
|
# describes an installation keeping the src.
|
|
|
|
preUnpack = ''
|
|
|
|
mkdir -p $out/share
|
|
|
|
cd $out/share
|
|
|
|
'';
|
2009-11-14 20:14:28 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
2012-08-26 22:15:02 +01:00
|
|
|
cd ..
|
|
|
|
if [ ! -d go ]; then
|
|
|
|
mv * go
|
|
|
|
fi
|
|
|
|
cd go
|
|
|
|
|
2015-01-08 09:26:49 +00:00
|
|
|
patchShebangs ./ # replace /bin/bash
|
2009-11-14 20:14:28 +00:00
|
|
|
# !!! substituteInPlace does not seems to be effective.
|
2010-06-12 12:21:20 +01:00
|
|
|
sed -i 's,/lib/ld-linux.so.2,${loader386},' src/cmd/8l/asm.c
|
|
|
|
sed -i 's,/lib64/ld-linux-x86-64.so.2,${loaderAmd64},' src/cmd/6l/asm.c
|
2012-08-24 15:00:18 +01:00
|
|
|
sed -i 's,/lib64/ld-linux-x86-64.so.3,${loaderArm},' src/cmd/5l/asm.c
|
2013-03-19 10:46:47 +00:00
|
|
|
sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/pkg/time/zoneinfo_unix.go
|
2010-06-12 12:21:20 +01:00
|
|
|
|
2012-07-29 16:24:19 +01:00
|
|
|
#sed -i -e 's,/bin/cat,${coreutils}/bin/cat,' \
|
|
|
|
# -e 's,/bin/echo,${coreutils}/bin/echo,' \
|
|
|
|
# src/pkg/exec/exec_test.go
|
2010-06-12 12:21:20 +01:00
|
|
|
|
2010-06-12 12:45:30 +01:00
|
|
|
# Disabling the 'os/http/net' tests (they want files not available in
|
|
|
|
# chroot builds)
|
2012-07-29 16:24:19 +01:00
|
|
|
rm src/pkg/net/{multicast_test.go,parse_test.go,port_test.go}
|
|
|
|
# The os test wants to read files in an existing path. Just it don't be /usr/bin.
|
|
|
|
sed -i 's,/usr/bin,'"`pwd`", src/pkg/os/os_test.go
|
|
|
|
sed -i 's,/bin/pwd,'"`type -P pwd`", src/pkg/os/os_test.go
|
|
|
|
# Disable the hostname test
|
|
|
|
sed -i '/TestHostname/areturn' src/pkg/os/os_test.go
|
2009-11-14 20:14:28 +00:00
|
|
|
'';
|
|
|
|
|
2014-07-02 11:11:45 +01:00
|
|
|
patches = [ ./cacert.patch ./1_0-opt-error.patch ./1_0-gcc-bug.patch ];
|
2012-07-29 16:24:19 +01:00
|
|
|
|
2009-11-14 20:14:28 +00:00
|
|
|
GOOS = "linux";
|
2012-12-28 18:54:15 +00:00
|
|
|
GOARCH = if stdenv.system == "i686-linux" then "386"
|
|
|
|
else if stdenv.system == "x86_64-linux" then "amd64"
|
|
|
|
else if stdenv.system == "armv5tel-linux" then "arm"
|
2010-06-12 12:21:20 +01:00
|
|
|
else throw "Unsupported system";
|
2012-08-24 15:00:18 +01:00
|
|
|
GOARM = stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") "5";
|
2009-11-14 20:14:28 +00:00
|
|
|
|
2014-11-26 22:37:50 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error=cpp";
|
|
|
|
|
2009-11-14 20:14:28 +00:00
|
|
|
installPhase = ''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p "$out/bin"
|
2009-11-14 20:14:28 +00:00
|
|
|
export GOROOT="$(pwd)/"
|
|
|
|
export GOBIN="$out/bin"
|
|
|
|
export PATH="$GOBIN:$PATH"
|
|
|
|
cd ./src
|
|
|
|
./all.bash
|
|
|
|
cd -
|
2009-11-16 18:42:43 +00:00
|
|
|
|
2012-07-29 16:24:19 +01:00
|
|
|
# Wrap the tools to define the location of the
|
2009-11-16 18:42:43 +00:00
|
|
|
# libraries.
|
2012-07-29 16:24:19 +01:00
|
|
|
for a in go gofmt godoc; do
|
|
|
|
wrapProgram "$out/bin/$a" \
|
2012-08-26 22:15:02 +01:00
|
|
|
--set "GOROOT" $out/share/go \
|
2012-12-28 18:54:15 +00:00
|
|
|
${if stdenv.system == "armv5tel-linux" then "--set GOARM $GOARM" else ""}
|
2012-07-29 16:24:19 +01:00
|
|
|
done
|
2009-11-16 18:42:43 +00:00
|
|
|
|
|
|
|
# Copy the emacs configuration for Go files.
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p "$out/share/emacs/site-lisp"
|
2012-07-29 16:24:19 +01:00
|
|
|
cp ./misc/emacs/* $out/share/emacs/site-lisp/
|
2009-11-14 20:14:28 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2014-11-03 11:12:47 +00:00
|
|
|
branch = "1.0";
|
2009-11-14 20:14:28 +00:00
|
|
|
homepage = http://golang.org/;
|
|
|
|
description = "The Go Programming language";
|
|
|
|
license = "BSD";
|
2010-06-12 12:21:20 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ pierron viric ];
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2009-11-14 20:14:28 +00:00
|
|
|
};
|
|
|
|
}
|