depot/hosts/VEGAS/services/object-storage/default.nix

71 lines
2 KiB
Nix
Raw Permalink Normal View History

{ config, inputs, lib, pkgs, tools, ... }:
2021-10-16 20:59:06 +03:00
with tools.nginx;
let
2022-06-18 03:44:51 +03:00
inherit (config) links;
2022-05-27 00:27:49 +03:00
mapPaths = lib.mapAttrsRecursive (
path: value: lib.nameValuePair
(lib.toUpper (lib.concatStringsSep "_" path))
(toString value)
);
translateConfig = config: lib.listToAttrs (
lib.collect
(x: x ? name && x ? value)
(mapPaths config)
);
2021-10-16 20:59:06 +03:00
in
{
2022-06-18 03:44:51 +03:00
links = {
minio.protocol = "http";
minioConsole.protocol = "http";
};
2021-11-29 02:38:59 +02:00
2021-10-16 20:59:06 +03:00
age.secrets.minio-root-credentials = {
file = ../../../../secrets/minio-root-credentials.age;
owner = "root";
group = "root";
mode = "0400";
};
services.minio = {
enable = true;
rootCredentialsFile = config.age.secrets.minio-root-credentials.path;
2021-10-16 20:59:06 +03:00
dataDir = [ "/srv/storage/objects" ];
browser = true;
2022-06-18 03:44:51 +03:00
listenAddress = links.minio.tuple;
consoleAddress = links.minioConsole.tuple;
2021-10-16 20:59:06 +03:00
};
systemd.services.minio.serviceConfig = {
Slice = "remotefshost.slice";
};
services.nginx.virtualHosts = mappers.mapSubdomains {
# TODO: vhosts.proxy?
"object-storage" = vhosts.basic // {
locations = {
2022-06-18 03:44:51 +03:00
"/".proxyPass = links.minio.url;
"= /dashboard".proxyPass = links.minio.url;
2021-10-16 20:59:06 +03:00
};
extraConfig = "client_max_body_size 4G;";
2021-10-16 20:59:06 +03:00
};
"console.object-storage" = vhosts.basic // {
locations = {
2022-06-18 03:44:51 +03:00
"/".proxyPass = links.minioConsole.url;
2021-10-16 20:59:06 +03:00
};
};
2022-06-18 03:44:51 +03:00
"cdn" = lib.recursiveUpdate (vhosts.proxy "${links.minio.url}/content-delivery$request_uri") {
2021-10-16 20:59:06 +03:00
locations."= /".return = "302 /index.html";
};
};
2022-05-27 00:27:49 +03:00
systemd.services.minio.environment = translateConfig {
minio.browser_redirect_url = "https://console.object-storage.${domain}";
2022-05-27 00:27:49 +03:00
minio.identity_openid = {
enable = "on";
display_name = "Private Void Account";
config_url = "https://login.${domain}/auth/realms/master/.well-known/openid-configuration";
client_id = "net.privatevoid.object-storage1";
claim_name = "minio_policy";
redirect_uri_dynamic = "on";
};
};
2021-10-16 20:59:06 +03:00
}