depot/cluster/services/attic/server.nix

88 lines
1.8 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
2023-10-31 23:19:08 +02:00
inherit (config.networking) hostName;
2023-06-14 00:27:53 +03:00
in
{
imports = [
depot.inputs.attic.nixosModules.atticd
];
2023-10-31 23:19:08 +02:00
age.secrets = {
atticServerToken.file = ./attic-server-token.age;
atticDBCredentials = {
file = ./attic-db-credentials.age;
owner = "atticd";
};
atticS3Credentials = {
file = ./attic-s3-credentials.age;
owner = "atticd";
};
};
2023-06-14 00:27:53 +03:00
links.atticServer.protocol = "http";
services.atticd = {
enable = true;
credentialsFile = config.age.secrets.atticServerToken.path;
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 = config.age.secrets.atticS3Credentials.path;
PGPASSFILE = config.age.secrets.atticDBCredentials.path;
};
};
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
}