Skip to content

Commit

Permalink
feat: include hash in final build
Browse files Browse the repository at this point in the history
  • Loading branch information
drawbu committed Sep 3, 2024
1 parent 403c8c1 commit 7d3bf1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
templ
tailwindcss
makeWrapper
nix
];
preBuild =
let
Expand All @@ -118,11 +119,14 @@
inherit (builtins) length genList elemAt;
in
''
ldflags+=" -X main.hash=$(nix-hash ${./.})"
${builtins.concatStringsSep "\n" (
genList (
i: "install -D ${font}/share/fonts/woff2/iosevka-comfy-fixed-${elemAt targets i}.woff2 static/"
) (length targets)
)}
templ generate
tailwindcss -i static/style.css -o static/generated.css
'';
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
"app/pkg/routes/root"
)

var (
hash string;
)

func main() {
serv := app.Server{Port: 8080}
serv := app.Server{Port: 8080, Hash: hash}

serv.AddRoute("GET /", root.Handler)
serv.AddRoute("GET /health", health.Handler)
Expand Down
1 change: 1 addition & 0 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type Server struct {
Port int16
Hash string
}

func (serv *Server) Run() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/template.templ
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ templ (app *Server) Template(body templ.Component) {
opinions listed here are my own and not representative of any of my employers, past, future, and/or present.
</p>
<p>
Served by me, with site version 00000000, source code available
Served by me using Nix and Docker. Current build hash: "{ app.Hash }", source code available
<a href="https://github.com/drawbu/drawbu.dev" target="_blank" rel="noopener">here</a>.
</p>
</footer>
Expand Down

0 comments on commit 7d3bf1f

Please sign in to comment.