2024-12-27 01:46:11 -08:00
|
|
|
{ lib, config, inputs, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
nyazoom = inputs.nyazoom.packages.${pkgs.system}.default;
|
|
|
|
|
|
|
|
cfg = config.permafrost.nyazoom;
|
2024-12-27 22:02:45 -08:00
|
|
|
ACMEEnabled = config.permafrost.acme.enable;
|
2024-12-27 01:46:11 -08:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.permafrost.nyazoom = {
|
|
|
|
enable = lib.mkEnableOption "permafrost nixos module";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-12-27 02:58:39 -08:00
|
|
|
systemd.services.nyazoom = {
|
2024-12-27 05:28:19 -08:00
|
|
|
script = /* bash */''
|
|
|
|
export DATABASE_URL="sqlite:///var/lib/nyazoom/data"
|
|
|
|
export DIST_DIR="${nyazoom}/dist"
|
|
|
|
${lib.getExe nyazoom}
|
2024-12-27 01:46:11 -08:00
|
|
|
'';
|
2024-12-27 04:40:52 -08:00
|
|
|
wantedBy = [ "network.target" ];
|
2024-12-27 01:46:11 -08:00
|
|
|
wants = [ "network.target" ];
|
|
|
|
};
|
2024-12-27 04:40:52 -08:00
|
|
|
|
2024-12-27 05:42:42 -08:00
|
|
|
permafrost.nginx.enable = lib.mkDefault true;
|
2024-12-27 22:02:45 -08:00
|
|
|
permafrost.acme.certDomains = lib.mkIf ACMEEnabled [ "nyazoom.zynh.me" ];
|
2024-12-27 05:42:42 -08:00
|
|
|
services.nginx.virtualHosts."nyazoom.zynh.me" = {
|
|
|
|
serverName = "nyazoom.zynh.me";
|
2024-12-27 21:50:05 -08:00
|
|
|
forceSSL = lib.mkIf ACMEEnabled true;
|
2024-12-27 22:02:45 -08:00
|
|
|
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
|
2024-12-27 06:21:51 -08:00
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:3000";
|
|
|
|
extraConfig = /* nginx */ ''
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
client_max_body_size 11G;
|
|
|
|
'';
|
|
|
|
};
|
2024-12-27 05:42:42 -08:00
|
|
|
};
|
2024-12-27 01:46:11 -08:00
|
|
|
};
|
|
|
|
}
|