From e0b81b9c3cebf46f6b3f7da1760fd60597f12ff0 Mon Sep 17 00:00:00 2001 From: Hamish Hutchings Date: Mon, 11 Sep 2017 17:54:27 +0100 Subject: [PATCH 1/3] Traefik init at 1.3.8 --- lib/maintainers.nix | 1 + pkgs/servers/traefik/default.nix | 24 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 3 files changed, 26 insertions(+) create mode 100644 pkgs/servers/traefik/default.nix diff --git a/lib/maintainers.nix b/lib/maintainers.nix index e2ee441d9dd..03b442f0b21 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -237,6 +237,7 @@ guillaumekoenig = "Guillaume Koenig "; guyonvarch = "Joris Guyonvarch "; hakuch = "Jesse Haber-Kucharsky "; + hamhut1066 = "Hamish Hutchings "; havvy = "Ryan Scheel "; hbunke = "Hendrik Bunke "; hce = "Hans-Christian Esperer "; diff --git a/pkgs/servers/traefik/default.nix b/pkgs/servers/traefik/default.nix new file mode 100644 index 00000000000..0f10dcf744a --- /dev/null +++ b/pkgs/servers/traefik/default.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "traefik-${version}"; + version = "v1.3.8"; + + src = fetchurl { + url = "https://github.com/containous/traefik/releases/download/${version}/traefik"; + sha256 = "09m8svkqdrvayw871azzcb05dnbhbgb3c2380dw0v4wpcd0rqr9h"; + }; + + buildCommand = '' + mkdir -p $out/bin + cp $src $out/bin/traefik + chmod +x $out/bin/traefik + ''; + + meta = with stdenv.lib; { + homepage = https://traefik.io; + description = "Træfik, a modern reverse proxy"; + license = licenses.mit; + maintainers = with maintainers; [ hamhut1066 ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 95b9db6ba70..e75085dcba6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -820,6 +820,7 @@ with pkgs; }); caddy = callPackage ../servers/caddy { }; + traefik = callPackage ../servers/traefik { }; capstone = callPackage ../development/libraries/capstone { }; From 0cc4cb96bb53a1bf5192e292148e4a8c4d6ebf8c Mon Sep 17 00:00:00 2001 From: Hamish Hutchings Date: Mon, 18 Sep 2017 13:37:36 +0100 Subject: [PATCH 2/3] Change to using source files to build traefik --- pkgs/servers/traefik/default.nix | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/pkgs/servers/traefik/default.nix b/pkgs/servers/traefik/default.nix index 0f10dcf744a..6bfe9d32a4a 100644 --- a/pkgs/servers/traefik/default.nix +++ b/pkgs/servers/traefik/default.nix @@ -1,18 +1,34 @@ -{ stdenv, fetchurl }: +{ stdenv, buildGoPackage, fetchurl, bash, go-bindata}: -stdenv.mkDerivation rec { +buildGoPackage rec { name = "traefik-${version}"; version = "v1.3.8"; + goPackagePath = "github.com/containous/traefik"; + src = fetchurl { - url = "https://github.com/containous/traefik/releases/download/${version}/traefik"; - sha256 = "09m8svkqdrvayw871azzcb05dnbhbgb3c2380dw0v4wpcd0rqr9h"; + url = "https://github.com/containous/traefik/releases/download/${version}/traefik-${version}.src.tar.gz"; + sha256 = "6fce36dd30bb5ae5f91e69f2950f22fe7a74b920e80c6b441a0721122f6a6174"; }; - buildCommand = '' - mkdir -p $out/bin - cp $src $out/bin/traefik - chmod +x $out/bin/traefik + buildInputs = [ go-bindata ]; + sourceRoot = "."; + postUnpack = '' + files=`ls` + mkdir traefik + mv $files traefik/ + export sourceRoot="traefik" + ''; + + buildPhase = '' + cd go/src/github.com/containous/traefik + ${bash}/bin/bash ./script/make.sh generate + CGO_ENABLED=0 GOGC=off go build -v -ldflags "-s -w" -a -installsuffix nocgo -o dist/traefik ./cmd/traefik + ''; + + installPhase = '' + mkdir -p $bin/bin + cp ./dist/traefik $bin/bin/ ''; meta = with stdenv.lib; { From ad2004afd37f14ddce40871f0c9dbc2fe20b7dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 19 Sep 2017 08:12:36 +0100 Subject: [PATCH 3/3] traefik: link against libc, set build version/codename this way gethostbyname() works as indented --- pkgs/servers/traefik/default.nix | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/pkgs/servers/traefik/default.nix b/pkgs/servers/traefik/default.nix index 6bfe9d32a4a..f1fb1a34fc2 100644 --- a/pkgs/servers/traefik/default.nix +++ b/pkgs/servers/traefik/default.nix @@ -2,38 +2,42 @@ buildGoPackage rec { name = "traefik-${version}"; - version = "v1.3.8"; + version = "1.3.8"; goPackagePath = "github.com/containous/traefik"; src = fetchurl { - url = "https://github.com/containous/traefik/releases/download/${version}/traefik-${version}.src.tar.gz"; + url = "https://github.com/containous/traefik/releases/download/v${version}/traefik-v${version}.src.tar.gz"; sha256 = "6fce36dd30bb5ae5f91e69f2950f22fe7a74b920e80c6b441a0721122f6a6174"; }; - buildInputs = [ go-bindata ]; - sourceRoot = "."; - postUnpack = '' - files=`ls` - mkdir traefik - mv $files traefik/ - export sourceRoot="traefik" + buildInputs = [ go-bindata bash ]; + unpackPhase = '' + runHook preUnpack + mkdir traefik + tar -C traefik -xvzf $src + export sourceRoot="traefik" + runHook postUnpack ''; buildPhase = '' - cd go/src/github.com/containous/traefik - ${bash}/bin/bash ./script/make.sh generate - CGO_ENABLED=0 GOGC=off go build -v -ldflags "-s -w" -a -installsuffix nocgo -o dist/traefik ./cmd/traefik - ''; + runHook preBuild + ( + cd go/src/github.com/containous/traefik + bash ./script/make.sh generate - installPhase = '' - mkdir -p $bin/bin - cp ./dist/traefik $bin/bin/ + CODENAME=$(awk -F "=" '/CODENAME=/ { print $2}' script/binary) + go build -ldflags "\ + -X github.com/containous/traefik/version.Version=${version} \ + -X github.com/containous/traefik/version.Codename=$CODENAME \ + " -a -o $bin/bin/traefik ./cmd/traefik + ) + runHook postBuild ''; meta = with stdenv.lib; { homepage = https://traefik.io; - description = "Træfik, a modern reverse proxy"; + description = "A modern reverse proxy"; license = licenses.mit; maintainers = with maintainers; [ hamhut1066 ]; };