working garbage collector

This commit is contained in:
Quentin 2023-03-24 16:46:31 +01:00
parent dbd4922f9a
commit 3781696316
Signed by: quentin
GPG key ID: E9602264D639FF68
3 changed files with 39 additions and 2 deletions

View file

@ -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
}
}
}
}

View file

@ -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

View file

@ -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")
}