2023-10-31 23:19:08 +02:00
|
|
|
{ cluster, config, depot, lib, ... }:
|
2023-06-14 00:27:53 +03:00
|
|
|
|
|
|
|
let
|
2024-07-08 20:00:55 +03:00
|
|
|
inherit (cluster.config.services.attic) secrets;
|
2024-08-02 23:46:45 +03:00
|
|
|
|
|
|
|
link = cluster.config.hostLinks.${config.networking.hostName}.attic;
|
|
|
|
|
|
|
|
isMonolith = lib.elem config.networking.hostName cluster.config.services.attic.nodes.monolith;
|
2023-06-14 00:27:53 +03:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2024-07-11 00:54:07 +03:00
|
|
|
services.locksmith.waitForSecrets.atticd = [ "garage-attic" ];
|
|
|
|
|
2023-06-14 00:27:53 +03:00
|
|
|
services.atticd = {
|
|
|
|
enable = true;
|
2024-07-16 03:14:59 +03:00
|
|
|
package = depot.inputs.attic.packages.attic-server;
|
2023-06-14 00:27:53 +03:00
|
|
|
|
2024-07-08 20:00:55 +03:00
|
|
|
credentialsFile = secrets.serverToken.path;
|
2024-08-02 23:46:45 +03:00
|
|
|
mode = if isMonolith then "monolithic" else "api-server";
|
2023-06-14 00:27:53 +03:00
|
|
|
|
|
|
|
settings = {
|
2024-08-02 23:46:45 +03:00
|
|
|
listen = link.tuple;
|
2023-06-14 00:27:53 +03:00
|
|
|
|
|
|
|
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";
|
2023-11-03 22:46:40 +02:00
|
|
|
endpoint = cluster.config.links.garageS3.url;
|
2023-10-31 23:19:08 +02:00
|
|
|
bucket = "attic";
|
2023-06-14 00:27:53 +03:00
|
|
|
};
|
2023-12-02 01:18:10 +02:00
|
|
|
|
|
|
|
garbage-collection = {
|
|
|
|
interval = "2 weeks";
|
|
|
|
default-retention-period = "3 months";
|
|
|
|
};
|
2023-06-14 00:27:53 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-12-02 01:10:58 +02: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 = {
|
2023-12-02 00:22:01 +02:00
|
|
|
after = [ "postgresql.service" ];
|
2024-08-02 23:46:45 +03:00
|
|
|
distributed = lib.mkIf isMonolith {
|
|
|
|
enable = true;
|
|
|
|
registerService = "atticd";
|
|
|
|
};
|
2023-12-02 01:10:58 +02:00
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = lib.mkForce false;
|
2024-08-02 23:46:45 +03:00
|
|
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" "AF_NETLINK" ];
|
2023-12-02 01:10:58 +02:00
|
|
|
};
|
2023-10-31 23:19:08 +02:00
|
|
|
environment = {
|
2024-07-11 00:54:07 +03:00
|
|
|
AWS_SHARED_CREDENTIALS_FILE = "/run/locksmith/garage-attic";
|
2024-07-08 20:00:55 +03:00
|
|
|
PGPASSFILE = secrets.dbCredentials.path;
|
2023-10-31 23:19:08 +02:00
|
|
|
};
|
2023-06-14 03:10:29 +03:00
|
|
|
};
|
2023-06-14 00:27:53 +03:00
|
|
|
|
2024-08-02 23:46:45 +03:00
|
|
|
consul.services.atticd = {
|
|
|
|
mode = if isMonolith then "manual" else "direct";
|
|
|
|
definition = {
|
|
|
|
name = "atticd";
|
2024-08-23 04:36:19 +03:00
|
|
|
id = "atticd-${config.services.atticd.mode}";
|
2024-08-02 23:46:45 +03:00
|
|
|
address = link.ipv4;
|
|
|
|
inherit (link) port;
|
|
|
|
checks = [
|
|
|
|
{
|
|
|
|
name = "Attic Server";
|
|
|
|
id = "service:atticd:backend";
|
|
|
|
interval = "5s";
|
|
|
|
http = link.url;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-06-16 18:27:40 +03:00
|
|
|
};
|
2023-06-14 00:27:53 +03:00
|
|
|
}
|