depot/cluster/services/attic/server.nix

74 lines
1.5 KiB
Nix
Raw Normal View History

2023-10-31 23:19:08 +02:00
{ cluster, config, depot, lib, ... }:
2023-06-14 00:27:53 +03:00
let
inherit (cluster.config.services.attic) secrets;
2023-06-14 00:27:53 +03:00
in
{
imports = [
depot.inputs.attic.nixosModules.atticd
];
links.atticServer.protocol = "http";
services.atticd = {
enable = true;
credentialsFile = secrets.serverToken.path;
2023-06-14 00:27:53 +03:00
settings = {
listen = config.links.atticServer.tuple;
chunking = {
2023-10-31 23:19:08 +02:00
nar-size-threshold = 0;
min-size = 0;
avg-size = 0;
max-size = 0;
2023-06-14 00:27:53 +03:00
};
2023-10-31 23:19:08 +02:00
compression.type = "none";
database.url = "postgresql://attic@${cluster.config.links.patroni-pg-access.tuple}/attic";
2023-06-14 00:27:53 +03:00
storage = {
2023-10-31 23:19:08 +02:00
type = "s3";
region = "us-east-1";
endpoint = cluster.config.links.garageS3.url;
2023-10-31 23:19:08 +02:00
bucket = "attic";
2023-06-14 00:27:53 +03:00
};
garbage-collection = {
interval = "2 weeks";
default-retention-period = "3 months";
};
2023-06-14 00:27:53 +03:00
};
};
users = {
users.atticd = {
isSystemUser = true;
group = "atticd";
home = "/var/lib/atticd";
createHome = true;
};
groups.atticd = {};
};
2023-10-31 23:19:08 +02:00
systemd.services.atticd = {
after = [ "postgresql.service" ];
serviceConfig = {
DynamicUser = lib.mkForce false;
};
2023-10-31 23:19:08 +02:00
environment = {
AWS_SHARED_CREDENTIALS_FILE = secrets.s3Credentials.path;
PGPASSFILE = secrets.dbCredentials.path;
2023-10-31 23:19:08 +02:00
};
};
2023-06-14 00:27:53 +03:00
2023-08-31 01:55:45 +03:00
services.nginx.virtualHosts."cache-api.${depot.lib.meta.domain}" = depot.lib.nginx.vhosts.proxy config.links.atticServer.url // {
extraConfig = ''
client_max_body_size 4G;
'';
};
2023-06-14 00:27:53 +03:00
}