1
0
Fork 0
dotfiles/system/nixos/atticd.nix

64 lines
1.4 KiB
Nix
Raw Normal View History

2023-05-25 13:21:06 +00:00
{ pkgs, config, lib, secret, ... }:
2023-04-04 15:20:09 +00:00
2023-04-04 20:30:12 +00:00
let
fqdn = "attic.cache.daniel.sx";
in
2023-04-04 15:20:09 +00:00
{
2023-04-04 20:43:16 +00:00
environment.systemPackages = [ pkgs.attic-client ];
2023-04-04 20:30:12 +00:00
2023-04-04 15:20:09 +00:00
services.atticd = {
enable = true;
credentialsFile = config.age.secrets.atticd-environment.path;
settings = {
listen = "127.0.0.1:8080";
2023-04-05 10:22:05 +00:00
database.url = secret.atticd.database-url;
2023-04-04 15:20:09 +00:00
2023-04-04 20:30:12 +00:00
allowed-hosts = [ "${fqdn}" ];
api-endpoint = "https://${fqdn}/";
2023-04-04 15:20:09 +00:00
storage = {
type = "s3";
2023-04-05 08:42:21 +00:00
region = "auto";
2023-04-04 15:20:09 +00:00
bucket = "attic-cache";
2023-04-04 15:22:37 +00:00
endpoint = "https://${secret.cloudflare.account-id}.r2.cloudflarestorage.com";
2023-04-04 15:20:09 +00:00
};
chunking = {
nar-size-threshold = 64 * 1024; # 64 KiB
min-size = 16 * 1024; # 16 KiB
avg-size = 64 * 1024; # 64 KiB
max-size = 256 * 1024; # 256 KiB
};
garbage-collection = {
interval = "12 hours";
2023-04-05 12:17:58 +00:00
default-retention-period = "2 weeks";
2023-04-04 15:20:09 +00:00
};
};
};
2023-04-04 20:30:12 +00:00
2023-05-25 13:21:06 +00:00
systemd.services.atticd = {
after = lib.mkForce [ "network.target" "network-online.target" ];
wants = [ "network.target" "network-online.target" ];
};
2023-04-04 20:30:12 +00:00
services.nginx.virtualHosts."${fqdn}" = {
quic = true;
http3 = true;
onlySSL = true;
useACMEHost = "cache.daniel.sx";
extraConfig = ''
client_max_body_size 0;
'';
2023-04-04 20:30:12 +00:00
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:8080";
};
};
2023-04-04 15:20:09 +00:00
}