Commit 3cce73c964cb

Vincent Demeester <vincent@sbr.pm>
2018-09-15 19:52:07
Don't use `buildGoPackage` for stellar…
… on 18.09 it tries to build with 1.9.x which doesn't work for some packages (like caddy) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 2811add
Changed files (3)
overlays/sbr.overlay.nix
@@ -18,6 +18,6 @@ self: super: {
     inherit (self) stdenv lib fetchFromGitHub go;
   };
   stellar = import ../pkgs/stellar {
-    inherit (self) stdenv lib buildGoPackage fetchFromGitHub;
+    inherit (self) stdenv lib fetchFromGitHub removeReferencesTo go;
   };
 }
pkgs/stellar/default.nix
@@ -1,24 +1,11 @@
-{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+{ stdenv, lib, fetchFromGitHub, removeReferencesTo, go}:
 
-buildGoPackage rec {
+stdenv.mkDerivation rec {
   name = "stellar-${version}";
   version = "0.1.0";
-  commit = "ae539df7b6796565a77365252350450113682e0b";
+  commit = "ae539df";
   rev = "v${version}";
 
-  goPackagePath = "github.com/ehazlett/stellar";
-
-  buildFlagsArray = [''-ldflags=
-    -X github.com/$(REPO)/version.GitCommit=${commit}
-    -X github.com/$(REPO)/version.Build=${version}
-  ''];
-  /*
-  subPackages = [
-    "cmd/etcd"
-    "cmd/etcdctl"
-  ];
-  */
-
   src = fetchFromGitHub {
     inherit rev;
     owner = "ehazlett";
@@ -26,6 +13,32 @@ buildGoPackage rec {
     sha256 = "0gv0z9hf6bh926sga2wadr3bdkigqbl849lhc0552by6c0c8p5dk";
   };
 
+  makeFlags = ["COMMIT=${commit}"];
+
+  buildInputs = [ removeReferencesTo go];
+
+  preConfigure = ''
+    # Extract the source
+    cd "$NIX_BUILD_TOP"
+    mkdir -p "go/src/github.com/ehazlett"
+    mv "$sourceRoot" "go/src/github.com/ehazlett/stellar"
+    export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
+  '';
+
+  preBuild = ''
+    cd go/src/github.com/ehazlett/stellar
+    patchShebangs .
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/* $out/bin
+  '';
+
+  preFixup = ''
+    find $out -type f -exec remove-references-to -t ${go} '{}' +
+  '';
+
   meta = {
     description = "Simplified Container Runtime Cluster";
     homepage = "https://github.com/ehazlett/stellar";
pkgs/default.nix
@@ -23,6 +23,6 @@ rec {
     inherit (pkgs) stdenv lib fetchFromGitHub go;
   };
   stellar = import ./stellar {
-    inherit (pkgs) stdenv lib buildGoPackage fetchFromGitHub;
+    inherit (pkgs) stdenv lib fetchFromGitHub removeReferencesTo go;
   };
 }