depot/cluster/services/attic/server.nix

82 lines
1.7 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.hostLinks.${hostName}.garageS3.url;
bucket = "attic";
2023-06-14 00:27:53 +03:00
};
};
};
users = {
users.atticd = {
isSystemUser = true;
group = "atticd";
2023-10-31 23:19:08 +02:00
home = "/var/lib/atticd";
2023-06-14 00:27:53 +03:00
createHome = true;
};
groups.atticd = {};
};
2023-10-31 23:19:08 +02:00
systemd.services.atticd = {
serviceConfig = {
DynamicUser = lib.mkForce false;
};
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
}