diff --git a/hcl/builder.hcl b/hcl/builder.hcl index 3b1252e..9d541a0 100644 --- a/hcl/builder.hcl +++ b/hcl/builder.hcl @@ -125,6 +125,38 @@ job "builder" { memory = 4000 } } + task "garbage-collect-cache" { + driver = "docker" + config { + image = "nixpkgs/nix:nixos-22.11" + args = [ "/tmp/gc.sh" ] + volumes = [ + "local/gc.sh:/tmp/gc.sh", + "local/nix.conf:/etc/nix/nix.conf", + "/var/cache/albatros/nix:/nix", + ] + } + + lifecycle { + hook = "poststop" + sidecar = false + } + + template { + data = file("./nix.conf") + destination = "local/nix.conf" + } + + template { + data = file("./gc.sh") + destination = "local/gc.sh" + perms = "555" + } + + restart { + attempts = 0 + } + } } } diff --git a/hcl/pin.sh b/hcl/pin.sh index eca04cb..085186f 100644 --- a/hcl/pin.sh +++ b/hcl/pin.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash set -euxo pipefail +set -f # disable globbing -echo "hook on $DRV_PATH" +mkdir -p /nix/var/nix/gcroots/albatros +DRV_NAME=$(echo $DRV_PATH | cut -d '/' -f 4) +GCROOT=/nix/var/nix/gcroots/albatros/$DRV_NAME +rm -f $GCROOT +ln -s $DRV_PATH $GCROOT diff --git a/main.go b/main.go index a0e3486..5f30691 100644 --- a/main.go +++ b/main.go @@ -413,7 +413,7 @@ func main() { http.HandleFunc("/build", build) // launch - log.Println("Listen on :8080") + log.Println("Albatros listen on :8080") if err = http.ListenAndServe(":8080", nil); err != nil { log.Fatal("Can't start HTTP server") }