dotfiles/modules/nixos/services/glance/default.nix

83 lines
2 KiB
Nix
Raw Normal View History

2025-05-24 02:45:00 -05:00
{ config, flake, ... }:
let
2025-07-03 19:49:48 -05:00
inherit (flake.config.services.instances)
glance
jellyfin
web
;
inherit (flake.config.machines.devices) ceres mars deimos;
configHelpers = {
service = glance;
hostname = config.networking.hostName;
2025-07-03 21:01:55 -05:00
localhost = web.localhost.address1;
2025-07-03 19:49:48 -05:00
host = configHelpers.service.domains.url0;
};
2025-05-25 18:28:37 -05:00
configPath = ./config;
configImports = {
2025-07-03 20:11:18 -05:00
server = import (configPath + /server.nix) { inherit flake configHelpers; };
2025-05-25 18:28:37 -05:00
branding = import (configPath + /branding.nix);
theme = import (configPath + /theme.nix);
pages = import (configPath + /pages.nix) { inherit config flake; };
};
2025-05-24 02:45:00 -05:00
in
{
services = {
glance = {
enable = true;
2025-05-25 18:28:37 -05:00
settings = configImports;
};
2025-07-03 20:21:14 -05:00
caddy = {
virtualHosts = {
"${configHelpers.host}" = {
extraConfig = ''
2025-07-03 20:56:06 -05:00
@allowed_ips {
remote_ip ${mars.wireguard.ip0} ${deimos.wireguard.ip0}
}
2025-07-03 19:49:48 -05:00
2025-07-03 20:56:06 -05:00
handle @allowed_ips {
redir /.well-known/carddav /remote.php/dav/ 301
redir /.well-known/caldav /remote.php/dav/ 301
reverse_proxy ${ceres.wireguard.ip0}:${toString configHelpers.service.ports.port0}
}
handle {
respond "Access Denied" 403
}
2025-07-03 20:21:14 -05:00
tls ${configHelpers.service.ssl.cert} ${configHelpers.service.ssl.key}
'';
};
2025-07-03 19:49:48 -05:00
};
};
};
2025-05-25 18:28:37 -05:00
sops =
let
sopsPath = secret: {
2025-07-03 20:11:18 -05:00
path = "/run/secrets/${configHelpers.service.name}-${secret}";
2025-05-25 18:28:37 -05:00
owner = "root";
2025-05-26 14:56:10 -05:00
group = "root";
mode = "644";
2025-05-24 02:45:00 -05:00
};
2025-05-25 18:28:37 -05:00
in
{
secrets = builtins.listToAttrs (
map
(secret: {
2025-07-03 20:11:18 -05:00
name = "${configHelpers.service.name}-${secret}";
2025-05-25 18:28:37 -05:00
value = sopsPath secret;
})
[
# "key"
# "${user0}-pass"
jellyfin.name
]
);
2025-05-24 02:45:00 -05:00
};
networking = {
firewall = {
2025-07-03 20:56:06 -05:00
interfaces.wg0.allowedTCPPorts = [
2025-07-03 20:11:18 -05:00
configHelpers.service.ports.port0
2025-05-24 02:45:00 -05:00
];
};
};
}