mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 10:05:13 -05:00
91 lines
1.9 KiB
Nix
Executable file
91 lines
1.9 KiB
Nix
Executable file
{
|
|
flake,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (flake.config.machines.devices) server;
|
|
inherit (flake.config.services.instances) web wiki;
|
|
service = wiki;
|
|
localhost = web.localhost.address1;
|
|
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 = "wiki-js";
|
|
host = "/run/postgresql";
|
|
type = "postgres";
|
|
user = "wiki-js";
|
|
};
|
|
};
|
|
};
|
|
|
|
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
|
|
sopsPath = secret: {
|
|
path = "${service.sops.path0}/${secret}";
|
|
owner = "root";
|
|
mode = "600";
|
|
};
|
|
in {
|
|
secrets = builtins.listToAttrs (
|
|
map
|
|
(secret: {
|
|
name = "${service.name}/${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
[
|
|
"pass"
|
|
"ssh"
|
|
]
|
|
);
|
|
};
|
|
|
|
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
|
|
];
|
|
};
|
|
};
|
|
}
|