dotfiles/nixos/modules/services/wiki.nix

78 lines
1.6 KiB
Nix
Raw Normal View History

2024-10-19 15:04:13 -05:00
{
flake,
config,
...
}: let
inherit (flake.config.people) user0;
inherit (flake.config.people.user.${user0}) domain;
inherit (flake.config.system.device) server wildcard;
inherit (flake.config.service.instance.wiki) paths ports subdomain ssl sops name;
localhost = wildcard.ip.address1;
host = "${subdomain}.${domain.url1}";
in {
services = {
wiki-js = {
enable = true;
2024-10-19 15:11:53 -05:00
environmentFile = config.sops.secrets."${name}-pass".path;
2024-10-19 15:04:13 -05:00
settings = {
port = ports.port0;
bindIP = localhost;
db = {
type = "postgres";
2024-10-19 15:06:09 -05:00
host = paths.path1;
2024-10-19 15:04:13 -05:00
};
};
};
caddy = {
virtualHosts = {
"${host}" = {
extraConfig = ''
reverse_proxy ${localhost}:${toString ports.port0}
tls ${ssl.cert} ${ssl.key}
'';
};
};
};
};
sops = let
sopsSecrets = ["pass"];
sopsPath = secret: {
path = "${sops.path0}/${name}-${secret}";
owner = name;
mode = "600";
};
in {
secrets = builtins.listToAttrs (
map
(secret: {
name = "${name}-${secret}";
value = sopsPath secret;
})
sopsSecrets
);
};
fileSystems."/var/lib/${name}" = {
device = paths.path0;
fsType = "none";
options = ["bind"];
depends = [server.storage0.mount];
};
systemd.tmpfiles.rules = [
"Z ${paths.path0} 755 ${name} ${name} -"
"Z ${sops.path0} 755 ${name} ${name} -"
];
networking = {
firewall = {
allowedTCPPorts = [
ports.port0
];
};
};
}