Make git revision available for nix flake builds (#12331)

This commit is contained in:
0rphee 2024-12-25 11:26:53 -06:00 committed by GitHub
parent c262fe41ab
commit 7b9b9329b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -138,6 +138,8 @@
cp contrib/helix.png $out/share/icons/hicolor/256x256/apps cp contrib/helix.png $out/share/icons/hicolor/256x256/apps
installShellCompletion contrib/completion/hx.{bash,fish,zsh} 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 {}; helix = makeOverridableHelix self.packages.${system}.helix-unwrapped {};
default = self.packages.${system}.helix; default = self.packages.${system}.helix;

View file

@ -20,7 +20,8 @@ fn main() {
.output() .output()
.ok() .ok()
.filter(|output| output.status.success()) .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 calver = get_calver();
let version: Cow<_> = match &git_hash { let version: Cow<_> = match &git_hash {