fix(build): pass git hash to Nix builds via env var
- build.rs checks GIT_HASH env var before shelling out to git - flake.nix injects self.shortRev into the build environment - Remove version number from footer, keep only commit hash
This commit is contained in:
parent
9ceb1a2b69
commit
ed0cb2fd39
3 changed files with 11 additions and 9 deletions
7
build.rs
7
build.rs
|
|
@ -7,14 +7,15 @@ fn main() {
|
|||
}
|
||||
|
||||
fn git_hash() {
|
||||
let output = Command::new("git")
|
||||
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())
|
||||
.unwrap_or_default();
|
||||
let hash = output.trim();
|
||||
});
|
||||
let hash = hash.as_deref().map(str::trim).unwrap_or_default();
|
||||
println!("cargo:rustc-env=GIT_HASH={hash}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@
|
|||
<main class="mx-auto flex w-full max-w-5xl flex-col gap-8 px-6 py-10">
|
||||
{% include "partials/nav.html" %} {% block content %}{% endblock %}
|
||||
<footer class="mt-8 text-center text-xs tracking-widest text-text-muted" style="font-variant: small-caps">
|
||||
<p>B{rew}log by <a href="https://jnsgr.uk" class="text-text-muted hover:text-accent transition" target="_blank" rel="noreferrer noopener">jnsgruk</a> · {{ version_info.version }} · <a href="https://github.com/jnsgruk/brewlog/commit/{{ version_info.commit }}" class="text-text-muted hover:text-accent transition" target="_blank" rel="noreferrer noopener">{{ version_info.commit }}</a></p>
|
||||
<p>B{rew}log by <a href="https://jnsgr.uk" class="text-text-muted hover:text-accent transition" target="_blank" rel="noreferrer noopener">jnsgruk</a> · <a href="https://github.com/jnsgruk/brewlog/commit/{{ version_info.commit }}" class="text-text-muted hover:text-accent transition" target="_blank" rel="noreferrer noopener">{{ version_info.commit }}</a></p>
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue