From 7b9b9329b9d9567f0c5cfded453b4e8445525774 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Wed, 25 Dec 2024 11:26:53 -0600 Subject: [PATCH] Make git revision available for nix flake builds (#12331) --- flake.nix | 2 ++ helix-loader/build.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2f3be94e..1fda3fa9 100644 --- a/flake.nix +++ b/flake.nix @@ -138,6 +138,8 @@ cp contrib/helix.png $out/share/icons/hicolor/256x256/apps installShellCompletion contrib/completion/hx.{bash,fish,zsh} ''; + # set git revision for nix flake builds, see 'git_hash' in helix-loader/build.rs + HELIX_NIX_BUILD_REV = self.rev or self.dirtyRev or null; }); helix = makeOverridableHelix self.packages.${system}.helix-unwrapped {}; default = self.packages.${system}.helix; diff --git a/helix-loader/build.rs b/helix-loader/build.rs index ea068983..cfa3a9ad 100644 --- a/helix-loader/build.rs +++ b/helix-loader/build.rs @@ -20,7 +20,8 @@ fn main() { .output() .ok() .filter(|output| output.status.success()) - .and_then(|x| String::from_utf8(x.stdout).ok()); + .and_then(|x| String::from_utf8(x.stdout).ok()) + .or_else(|| option_env!("HELIX_NIX_BUILD_REV").map(|s| s.to_string())); let calver = get_calver(); let version: Cow<_> = match &git_hash {