mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 10:05:13 -05:00
88 lines
1.8 KiB
Nix
Executable file
88 lines
1.8 KiB
Nix
Executable file
{
|
|
flake,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (flake.config.system.device) server;
|
|
inherit (flake.config.service.instance) web wiki;
|
|
service = wiki;
|
|
localhost = web.localhost.address0;
|
|
host = "${service.subdomain}.${web.domains.url1}";
|
|
in {
|
|
services = {
|
|
wiki-js = {
|
|
enable = true;
|
|
environmentFile = config.sops.secrets."${service.name}-pass".path;
|
|
settings = {
|
|
port = service.ports.port0;
|
|
bindIP = localhost;
|
|
db = {
|
|
db = service.name;
|
|
type = "postgres";
|
|
host = host;
|
|
};
|
|
};
|
|
};
|
|
|
|
caddy = {
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
extraConfig = ''
|
|
reverse_proxy ${localhost}:${toString service.ports.port0}
|
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
postgresql = {
|
|
ensureDatabases = [service.name];
|
|
ensureUsers = [
|
|
{
|
|
name = service.name;
|
|
ensureDBOwnership = true;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
sops = let
|
|
sopsSecrets = ["pass"];
|
|
sopsPath = secret: {
|
|
path = "${service.sops.path0}/${service.name}-${secret}";
|
|
owner = "root";
|
|
mode = "600";
|
|
};
|
|
in {
|
|
secrets = builtins.listToAttrs (
|
|
map
|
|
(secret: {
|
|
name = "${service.name}-${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
sopsSecrets
|
|
);
|
|
};
|
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
device = service.paths.path0;
|
|
fsType = "none";
|
|
options = ["bind"];
|
|
depends = [server.storage0.mount];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
|
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
|
];
|
|
|
|
networking = {
|
|
firewall = {
|
|
allowedTCPPorts = [
|
|
service.ports.port0
|
|
service.ports.port1
|
|
];
|
|
};
|
|
};
|
|
}
|