2024-05-22 12:10:48 +02:00
|
|
|
{
|
|
|
|
inputs,
|
2024-07-18 02:09:23 +02:00
|
|
|
lib,
|
2024-05-22 12:10:48 +02:00
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-08-25 20:17:14 +02:00
|
|
|
inherit (lib.attrsets) attrValues;
|
2024-07-24 18:47:53 +02:00
|
|
|
inherit (lib.meta) getExe';
|
2024-07-18 02:09:23 +02:00
|
|
|
|
|
|
|
systemctl = getExe' pkgs.systemd "systemctl";
|
|
|
|
|
2024-05-22 12:10:48 +02:00
|
|
|
port = 4827;
|
2024-07-18 02:09:23 +02:00
|
|
|
sitePath = "/srv/web/jacekpoz.pl";
|
2024-05-22 12:10:48 +02:00
|
|
|
in {
|
2023-11-25 17:12:09 +01:00
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
2024-05-23 00:18:10 +02:00
|
|
|
virtualHosts = {
|
|
|
|
"jacekpoz.pl".extraConfig = ''
|
|
|
|
reverse_proxy localhost:${toString port}
|
|
|
|
'';
|
|
|
|
"jpoz.pl".extraConfig = ''
|
|
|
|
redir / https://jacekpoz.pl
|
|
|
|
redir /git https://jacekpoz.pl/posts/git-workflow.html
|
|
|
|
'';
|
|
|
|
"jacek.poziem.ski".extraConfig = ''
|
|
|
|
redir https://jacekpoz.pl
|
|
|
|
'';
|
|
|
|
};
|
2023-11-25 17:12:09 +01:00
|
|
|
};
|
2024-05-22 12:10:48 +02:00
|
|
|
|
2024-05-22 12:16:26 +02:00
|
|
|
users.groups.site = {};
|
|
|
|
|
|
|
|
users.users.site = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "site";
|
|
|
|
};
|
|
|
|
|
2024-07-18 02:09:23 +02:00
|
|
|
systemd = {
|
|
|
|
services = {
|
|
|
|
pozback = {
|
|
|
|
description = "The backend for jacekpoz.pl";
|
|
|
|
after = ["network.target"];
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${inputs.pozsite.packages.${pkgs.system}.pozback}/bin/back";
|
|
|
|
Restart = "on-failure";
|
|
|
|
Environment = ''POZ_PORT="${toString port}" POZ_DIR="${sitePath}"'';
|
|
|
|
User = "site";
|
|
|
|
Group = "site";
|
|
|
|
};
|
|
|
|
|
2024-08-25 20:17:14 +02:00
|
|
|
path = attrValues {
|
|
|
|
inherit (pkgs)
|
|
|
|
fastfetch
|
|
|
|
colorized-logs
|
|
|
|
;
|
|
|
|
};
|
2024-07-18 02:09:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
pozback-watcher = {
|
|
|
|
description = "Restarter for the backend";
|
|
|
|
after = ["network.target"];
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${systemctl} restart pozback.service";
|
|
|
|
};
|
|
|
|
};
|
2024-05-22 12:10:48 +02:00
|
|
|
};
|
2024-07-18 02:09:23 +02:00
|
|
|
paths.pozback-watcher = {
|
|
|
|
wantedBy = ["multi-user.target"];
|
2024-05-22 12:10:48 +02:00
|
|
|
|
2024-07-18 02:09:23 +02:00
|
|
|
pathConfig = {
|
|
|
|
PathModified = sitePath;
|
|
|
|
Unit = "pozback-watcher.service";
|
|
|
|
};
|
|
|
|
};
|
2024-05-22 12:10:48 +02:00
|
|
|
};
|
2023-11-25 17:12:09 +01:00
|
|
|
}
|