2023-08-28 03:32:08 +03:00
|
|
|
{ cluster, config, depot, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (cluster.config) vars;
|
|
|
|
inherit (config.networking) hostName;
|
|
|
|
|
|
|
|
links = cluster.config.hostLinks.${hostName};
|
|
|
|
|
|
|
|
cfg = config.services.garage;
|
|
|
|
|
|
|
|
# fixed uid so we know how to mount the underlay
|
|
|
|
uid = 777;
|
|
|
|
gid = 777;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
age.secrets.garageRpcSecret = {
|
|
|
|
file = ./secrets/garage-rpc-secret.age;
|
|
|
|
owner = "garage";
|
|
|
|
group = "garage";
|
|
|
|
};
|
|
|
|
|
2023-11-03 21:57:35 +02:00
|
|
|
system.ascensions.garage-layout = {
|
|
|
|
distributed = true;
|
|
|
|
requiredBy = [ "garage.service" ];
|
|
|
|
after = [ "garage.service" "garage-layout-init.service" ];
|
|
|
|
};
|
|
|
|
|
2023-08-28 03:32:08 +03:00
|
|
|
services.garage = {
|
|
|
|
enable = true;
|
|
|
|
package = depot.packages.garage;
|
|
|
|
settings = {
|
2024-06-04 15:53:12 +03:00
|
|
|
replication_mode = "3";
|
2023-08-28 03:32:08 +03:00
|
|
|
block_size = 16 * 1024 * 1024;
|
|
|
|
db_engine = "lmdb";
|
|
|
|
metadata_dir = "/var/lib/garage-metadata";
|
|
|
|
rpc_bind_addr = links.garageRpc.tuple;
|
|
|
|
rpc_public_addr = links.garageRpc.tuple;
|
|
|
|
rpc_secret_file = config.age.secrets.garageRpcSecret.path;
|
|
|
|
consul_discovery = {
|
|
|
|
consul_http_addr = "http://127.0.0.1:8500";
|
|
|
|
service_name = "garage-discovery";
|
|
|
|
};
|
|
|
|
s3_api = {
|
|
|
|
api_bind_addr = links.garageS3.tuple;
|
|
|
|
s3_region = "us-east-1";
|
|
|
|
};
|
2024-04-22 00:40:21 +03:00
|
|
|
s3_web = {
|
|
|
|
bind_addr = links.garageWeb.tuple;
|
|
|
|
root_domain = cluster.config.links.garageWeb.hostname;
|
|
|
|
};
|
2023-08-28 03:32:08 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
users.garage = {
|
|
|
|
inherit uid;
|
|
|
|
group = "garage";
|
|
|
|
};
|
|
|
|
groups.garage = {
|
|
|
|
inherit gid;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.garage = {
|
2023-10-31 16:16:03 +02:00
|
|
|
unitConfig = {
|
|
|
|
RequiresMountsFor = [ cfg.settings.data_dir ];
|
|
|
|
};
|
2023-08-28 03:32:08 +03:00
|
|
|
serviceConfig = {
|
|
|
|
IPAddressDeny = [ "any" ];
|
|
|
|
IPAddressAllow = [ "127.0.0.1/8" vars.meshNet.cidr ];
|
|
|
|
DynamicUser = false;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectSystem = true;
|
|
|
|
User = "garage";
|
|
|
|
Group = "garage";
|
2023-12-02 02:06:20 +02:00
|
|
|
StateDirectory = lib.mkForce (lib.removePrefix "/var/lib/" cfg.settings.metadata_dir);
|
2023-08-28 03:32:08 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|