Skip to content

Commit 1896a08

Browse files
authored
Allow setting the NU_COMMIT_HASH as an env variable (nushell#16947)
1 parent fda67bd commit 1896a08

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/nu-cmd-lang/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ use std::process::Command;
33
fn main() {
44
// Look up the current Git commit ourselves instead of relying on shadow_rs,
55
// because shadow_rs does it in a really slow-to-compile way (it builds libgit2)
6-
let hash = get_git_hash().unwrap_or_default();
6+
// Allow overriding it with `NU_COMMIT_HASH` from outside, such as with nix.
7+
let hash = get_git_hash().unwrap_or(
8+
option_env!("NU_COMMIT_HASH")
9+
.unwrap_or_default()
10+
.to_string(),
11+
);
712
println!("cargo:rustc-env=NU_COMMIT_HASH={hash}");
813
shadow_rs::ShadowBuilder::builder()
914
.build()

0 commit comments

Comments
 (0)