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·44+0200
committerVincent Ambo <mail@tazj.in>2021-04-30T11·27+0200
commit5c2db7b8ce4386bff4596eb0dfcc5d1f61dbf744 (patch)
treea7d80247060f9950b23e53435ba08af9603ffafc /tools/nixery/default.nix
parent7520f2cb96159ae3cbee80b4822900f9a92f7f53 (diff)
chore(build): Use current git commit hash as build version
Diffstat (limited to 'tools/nixery/default.nix')
-rw-r--r--tools/nixery/default.nix10
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/nixery/default.nix b/tools/nixery/default.nix
index 411865a8a40b..00ecad583c13 100644
--- a/tools/nixery/default.nix
+++ b/tools/nixery/default.nix
@@ -1,4 +1,4 @@
-# Copyright 2019 Google LLC
+# Copyright 2019-2021 Google LLC
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -22,12 +22,10 @@ with pkgs;
 let
   inherit (pkgs) buildGoPackage;
 
-  # Hash of all Nixery sources - this is used as the Nixery version in
+  # Current Nixery commit - this is used as the Nixery version in
   # builds to distinguish errors between deployed versions, see
   # server/logs.go for details.
-  nixery-src-hash = pkgs.runCommand "nixery-src-hash" {} ''
-    echo ${./.} | grep -Eo '[a-z0-9]{32}' | head -c 32 > $out
-  '';
+  nixery-commit-hash = pkgs.lib.commitIdFromGitRepo ./.git;
 
   # Go implementation of the Nixery server which implements the
   # container registry interface.
@@ -52,7 +50,7 @@ let
       runHook renameImport
 
       export GOBIN="$out/bin"
-      go install -ldflags "-X main.version=$(cat ${nixery-src-hash})" ${goPackagePath}
+      go install -ldflags "-X main.version=$(cat ${nixery-commit-hash})" ${goPackagePath}
     '';
 
     fixupPhase = ''