nixcfg/systems/x86_64-linux/attic/atticd.nix
Harald Hoyer 13a386fe98 feat(attic): add daily garbage collection timer
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:07:44 +01:00

85 lines
2.2 KiB
Nix

{
pkgs,
lib,
config,
...
}:
{
services.postgresql = {
enable = true;
ensureDatabases = [ "atticd" ];
ensureUsers = [{
name = "atticd";
ensureDBOwnership = true;
}];
};
environment.systemPackages = with pkgs; [ attic-client ];
services.atticd = {
enable = true;
# Replace with absolute path to your credentials file
environmentFile = "/etc/atticd.env";
settings = {
api-endpoint = "https://attic.teepot.org/";
garbage-collection.default-retention-period = "3 months";
database.url = "postgresql:///atticd?host=/run/postgresql";
listen = "[::]:8080";
storage = {
type = "s3";
bucket = "teepot-attic";
region = "hel1";
endpoint = "https://hel1.your-objectstorage.com";
};
# Data chunking
#
# Warning: If you change any of the values here, it will be
# difficult to reuse existing chunks for newly-uploaded NARs
# since the cutpoints will be different. As a result, the
# deduplication ratio will suffer for a while after the change.
chunking = {
# The minimum NAR size to trigger chunking
#
# If 0, chunking is disabled entirely for newly-uploaded NARs.
# If 1, all NARs are chunked.
nar-size-threshold = 64 * 1024; # 64 KiB
# The preferred minimum size of a chunk, in bytes
min-size = 16 * 1024; # 16 KiB
# The preferred average size of a chunk, in bytes
avg-size = 64 * 1024; # 64 KiB
# The preferred maximum size of a chunk, in bytes
max-size = 256 * 1024; # 256 KiB
};
};
};
systemd.services.atticd-gc = {
description = "Attic garbage collection";
requires = [ "atticd.service" ];
after = [ "atticd.service" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.attic-server}/bin/atticd-atticadm gc";
EnvironmentFile = "/etc/atticd.env";
};
};
systemd.timers.atticd-gc = {
description = "Daily Attic garbage collection";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
RandomizedDelaySec = "1h";
};
};
}