about summary refs log tree commit diff stats
path: root/nix
diff options
context:
space:
mode:
authorAlan Pearce2024-05-14 21:16:23 +0200
committerAlan Pearce2024-05-14 21:45:02 +0200
commit1a5c82e2d08accb6330c4164ab987b87157b10ed (patch)
tree48d6a913809e60b1a0cc28a8b67413ffaf979f97 /nix
parentf08094f23aa4dc7d63a7c98b4429d88005fe3a2d (diff)
downloadsearchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.tar.lz
searchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.tar.zst
searchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.zip
build: bake git hash into build for headers and --version
Diffstat (limited to 'nix')
-rw-r--r--nix/package.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/nix/package.nix b/nix/package.nix
index 5e47c9b..d311505 100644
--- a/nix/package.nix
+++ b/nix/package.nix
@@ -12,11 +12,12 @@
 , buildGoApplication ? pkgs.buildGoApplication
 , css
 , self
+, testers
 }:
 let
   inherit (builtins) concatStringsSep match;
 
-  version = concatStringsSep "-" (match
+  version = "0-unstable-" + concatStringsSep "-" (match
     "([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2}).*"
     self.lastModifiedDate
   );
@@ -42,5 +43,16 @@ buildGoApplication {
     cp ${css} frontend/static/base.css
   '';
   tags = [ "embed" ];
+  ldflags = [
+    "-s"
+    "-w"
+    "-X"
+    "searchix/internal/config.CommitSHA=${self.rev or self.dirtyRev}"
+    "-X"
+    "searchix/internal/config.ShortSHA=${self.shortRev or self.dirtyShortRev}"
+    "-X"
+    "main.buildVersion=${version}"
+  ];
+
   modules = ../gomod2nix.toml;
 }