()
| 13 | } |
| 14 | |
| 15 | fn 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 | |
| 37 | fn is_nix_build() -> bool { |
| 38 | nix_injected_commit_hash().is_some() |
no outgoing calls
no test coverage detected
searching dependent graphs…