MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / nix_injected_commit_hash

Function nix_injected_commit_hash

crates/cli/build.rs:15–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15fn nix_injected_commit_hash() -> Option<String> {
16 use std::env::VarError;
17 // Our flake.nix sets this environment variable to be our git commit hash during the build.
18 // This is important because git metadata is otherwise not available within the nix build sandbox,
19 // and we don't install the git command-line tool in our build.
20 match std::env::var("SPACETIMEDB_NIX_BUILD_GIT_COMMIT") {
21 Ok(commit_sha) => {
22 // Var is set, we're building under Nix.
23 Some(commit_sha)
24 }
25
26 Err(VarError::NotPresent) => {
27 // Var is not set, we're not in Nix.
28 None
29 }
30 Err(VarError::NotUnicode(gross)) => {
31 // Var is set but is invalid unicode, something is very wrong.
32 panic!("Injected commit hash is not valid unicode: {gross:?}")
33 }
34 }
35}
36
37fn is_nix_build() -> bool {
38 nix_injected_commit_hash().is_some()

Callers 2

is_nix_buildFunction · 0.70
find_git_hashFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…