about summary refs log tree commit diff
path: root/tools/nixery/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2021-04-30T10·56+0200
committerVincent Ambo <mail@tazj.in>2021-04-30T11·27+0200
commit13d97c9e51a3c6cc2abcb354bcd0519a49aeed68 (patch)
treed86608e804d13d9e5362f6b1f174ac03ccfbfd92 /tools/nixery/default.nix
parent5c2db7b8ce4386bff4596eb0dfcc5d1f61dbf744 (diff)
refactor(build): Pin dependencies using Go modules
Drops the go2nix configuration in favour of pkgs.buildGoModule.

Note that the go.sum file is bloated by issues with cyclic
dependencies in some Google projects, but this large number of
dependencies is not actually built.
Diffstat (limited to 'tools/nixery/default.nix')
-rw-r--r--tools/nixery/default.nix32
1 files changed, 7 insertions, 25 deletions
diff --git a/tools/nixery/default.nix b/tools/nixery/default.nix
index 00ecad583c13..a5cc61e7e2ee 100644
--- a/tools/nixery/default.nix
+++ b/tools/nixery/default.nix
@@ -20,7 +20,7 @@
 with pkgs;
 
 let
-  inherit (pkgs) buildGoPackage;
+  inherit (pkgs) buildGoModule;
 
   # Current Nixery commit - this is used as the Nixery version in
   # builds to distinguish errors between deployed versions, see
@@ -32,35 +32,17 @@ let
   #
   # Users should use the nixery-bin derivation below instead as it
   # provides the paths of files needed at runtime.
-  nixery-server = buildGoPackage rec {
+  nixery-server = buildGoModule rec {
     name = "nixery-server";
-    goDeps = ./go-deps.nix;
     src = ./.;
-
-    goPackagePath = "github.com/google/nixery";
     doCheck = true;
 
-    # Simplify the Nix build instructions for Go to just the basics
-    # required to get Nixery up and running with the additional linker
-    # flags required.
-    outputs = [ "out" ];
-    preConfigure = "bin=$out";
-    buildPhase = ''
-      runHook preBuild
-      runHook renameImport
-
-      export GOBIN="$out/bin"
-      go install -ldflags "-X main.version=$(cat ${nixery-commit-hash})" ${goPackagePath}
-    '';
+    # Needs to be updated after every modification of go.mod/go.sum
+    vendorSha256 = "1ff0kfww6fy6pnvyva7x8cc6l1d12aafps48wrkwawk2qjy9a8b9";
 
-    fixupPhase = ''
-      remove-references-to -t ${go} $out/bin/nixery
-    '';
-
-    checkPhase = ''
-      go vet ${goPackagePath}
-      go test ${goPackagePath}
-    '';
+    buildFlagsArray = [
+      "-ldflags=-s -w -X main.version=${nixery-commit-hash}"
+    ];
   };
 in rec {
   # Implementation of the Nix image building logic