niksos/hosts/chmura/nixwebr.ing.nix

67 lines
1.8 KiB
Nix

{
inputs,
lib,
pkgs,
...
}: let
inherit (lib.meta) getExe';
systemctl = getExe' pkgs.systemd "systemctl";
port = 5932;
sitePath = "/srv/web/nixwebr.ing";
in {
services.caddy = {
enable = true;
virtualHosts = {
"nixwebr.ing".extraConfig = ''
reverse_proxy localhost:${toString port}
'';
};
};
users.groups.nixwebring = {};
users.users.nixwebring = {
isSystemUser = true;
group = "nixwebring";
};
systemd = {
services = {
nix-webring-server = {
description = "The backend for nixwebr.ing";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${inputs.nix-webring.packages.${pkgs.system}.server}/bin/nix-webring-server";
Restart = "on-failure";
Environment = ''NIX_WEBRING_PORT="${toString port}" NIX_WEBRING_DIR="${sitePath}"'';
User = "nixwebring";
Group = "nixwebring";
};
};
nix-webring-server-watcher = {
description = "Restarter for the backend";
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "oneshot";
ExecStart = "${systemctl} restart nix-webring-server.service";
};
};
};
paths.nix-webring-server-watcher = {
wantedBy = ["multi-user.target"];
pathConfig = {
PathModified = sitePath;
Unit = "nix-webring-server-watcher.service";
};
};
};
}