diff --git a/build.rs b/build.rs index 1bd3a21..438f245 100644 --- a/build.rs +++ b/build.rs @@ -7,14 +7,15 @@ fn main() { } fn git_hash() { - let output = Command::new("git") - .args(["rev-parse", "--short", "HEAD"]) - .output() - .ok() - .filter(|o| o.status.success()) - .and_then(|o| String::from_utf8(o.stdout).ok()) - .unwrap_or_default(); - let hash = output.trim(); + let hash = std::env::var("GIT_HASH").ok().or_else(|| { + Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .output() + .ok() + .filter(|o| o.status.success()) + .and_then(|o| String::from_utf8(o.stdout).ok()) + }); + let hash = hash.as_deref().map(str::trim).unwrap_or_default(); println!("cargo:rustc-env=GIT_HASH={hash}"); } diff --git a/flake.nix b/flake.nix index bf26248..889746d 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,7 @@ stdenv.cc.cc.lib ]; + env.GIT_HASH = self.shortRev or self.dirtyShortRev or "dev"; env.LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.openssl ]; meta = { diff --git a/templates/base.html b/templates/base.html index b3a6764..386369a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -116,7 +116,7 @@
{% include "partials/nav.html" %} {% block content %}{% endblock %}