2023-11-29 16:12:24 +01:00
|
|
|
{ config, pkgs, ... }:
|
2023-09-11 11:17:52 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
host = "s3.dgnum.eu";
|
|
|
|
webHost = "cdn.dgnum.eu";
|
2023-09-17 18:13:35 +02:00
|
|
|
|
|
|
|
data_dir = "/data/slow/garage/data";
|
|
|
|
metadata_dir = "/data/fast/garage/meta";
|
2023-10-05 23:28:27 +02:00
|
|
|
|
2024-03-06 22:53:24 +01:00
|
|
|
buckets = [
|
|
|
|
"castopod-dgnum"
|
|
|
|
"peertube-videos-dgnum"
|
|
|
|
];
|
2024-02-02 10:51:31 +01:00
|
|
|
in
|
|
|
|
{
|
2023-09-11 11:17:52 +02:00
|
|
|
services.garage = {
|
|
|
|
enable = true;
|
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
package = pkgs.garage_0_9.overrideAttrs (
|
|
|
|
old: {
|
|
|
|
patches = (old.patches or [ ]) ++ [
|
|
|
|
# Allow 0 as a part number marker
|
|
|
|
(pkgs.fetchpatch {
|
|
|
|
url = "https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/670.patch";
|
|
|
|
hash = "sha256-28ctLl1qscMRj2JEVnmhuLyK1Avub8QeyfQFxAK0y08=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|
|
|
|
);
|
2023-11-29 16:12:24 +01:00
|
|
|
|
2023-09-11 11:17:52 +02:00
|
|
|
settings = {
|
2023-09-17 18:13:35 +02:00
|
|
|
inherit data_dir metadata_dir;
|
|
|
|
|
2023-12-05 23:41:26 +01:00
|
|
|
db_engine = "lmdb";
|
2023-11-29 16:12:24 +01:00
|
|
|
|
2023-09-11 11:17:52 +02:00
|
|
|
replication_mode = "none";
|
|
|
|
compression_level = 7;
|
|
|
|
|
|
|
|
rpc_bind_addr = "[::]:3901";
|
|
|
|
rpc_public_addr = "127.0.0.1:3901";
|
|
|
|
|
|
|
|
s3_api = {
|
2023-09-11 18:54:17 +02:00
|
|
|
s3_region = "garage";
|
|
|
|
api_bind_addr = "127.0.0.1:3900";
|
2023-09-11 11:17:52 +02:00
|
|
|
root_domain = ".${host}";
|
|
|
|
};
|
|
|
|
|
|
|
|
s3_web = {
|
2023-09-11 18:54:17 +02:00
|
|
|
bind_addr = "127.0.0.1:3902";
|
2023-09-11 11:17:52 +02:00
|
|
|
root_domain = ".${webHost}";
|
|
|
|
index = "index.html";
|
|
|
|
};
|
|
|
|
|
2023-10-05 23:28:27 +02:00
|
|
|
k2v_api.api_bind_addr = "[::]:3904";
|
2023-09-11 11:17:52 +02:00
|
|
|
|
2023-10-05 23:28:27 +02:00
|
|
|
admin.api_bind_addr = "0.0.0.0:3903";
|
2023-09-11 11:17:52 +02:00
|
|
|
};
|
2023-09-24 13:27:14 +02:00
|
|
|
|
|
|
|
environmentFile = config.age.secrets."garage-environment_file".path;
|
2023-09-11 11:17:52 +02:00
|
|
|
};
|
|
|
|
|
2023-09-17 18:13:35 +02:00
|
|
|
systemd.services.garage.serviceConfig = {
|
|
|
|
User = "garage";
|
2024-02-02 10:51:31 +01:00
|
|
|
ReadWriteDirectories = [
|
|
|
|
data_dir
|
|
|
|
metadata_dir
|
|
|
|
];
|
2023-09-17 18:13:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
users.users.garage = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "garage";
|
|
|
|
};
|
|
|
|
users.groups.garage = { };
|
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
${host} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-10-05 23:28:27 +02:00
|
|
|
|
|
|
|
serverAliases = builtins.map (b: "${b}.${host}") buckets;
|
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
locations."/".extraConfig = ''
|
|
|
|
proxy_pass http://127.0.0.1:3900;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
# Disable buffering to a temporary file.
|
|
|
|
proxy_max_temp_file_size 0;
|
2023-12-08 14:52:51 +01:00
|
|
|
client_max_body_size 5G;
|
2023-09-11 18:54:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
${webHost} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-10-05 23:28:27 +02:00
|
|
|
|
|
|
|
serverAliases = builtins.map (b: "${b}.${webHost}") buckets;
|
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
locations."/".extraConfig = ''
|
|
|
|
proxy_pass http://127.0.0.1:3902;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $host;'';
|
|
|
|
};
|
2023-09-11 11:17:52 +02:00
|
|
|
};
|
|
|
|
}
|