From 2a15fc044537a07fec61bf1dc003175309e5b067 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= <tmuehlbacher@posteo.net>
Date: Thu, 6 Jun 2024 17:58:22 +0200
Subject: [PATCH] build(nix): use actual commit rev in version
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This way we get an actually unique version for every version that can be
traced back to the source.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
---
 flake.nix | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/flake.nix b/flake.nix
index 5222d655..e4bc38ea 100644
--- a/flake.nix
+++ b/flake.nix
@@ -66,11 +66,11 @@
 
           craneLib = crane.mkLib pkgs;
 
-          libbcachefsCommit = substring 0 7 (builtins.readFile ./.bcachefs_revision);
+          rev = self.shortRev or self.dirtyShortRev or (substring 0 8 self.lastModifiedDate);
           makefileVersion = removePrefix "VERSION=" (
             findFirst (line: hasPrefix "VERSION=" line) "VERSION=0.0.0" (split "\n" (readFile ./Makefile))
           );
-          version = "${makefileVersion}+git-${libbcachefsCommit}";
+          version = "${makefileVersion}+${rev}";
 
           commonArgs = {
             inherit version;