permafrost/modules/nyazoom.nix
2024-12-27 22:43:43 -08:00

41 lines
1.2 KiB
Nix

{ lib, config, inputs, pkgs, ... }:
let
nyazoom = inputs.nyazoom.packages.${pkgs.system}.default;
cfg = config.permafrost.nyazoom;
ACMEEnabled = config.permafrost.acme.enable;
in
{
options.permafrost.nyazoom = {
enable = lib.mkEnableOption "permafrost nixos module";
};
config = lib.mkIf cfg.enable {
systemd.services.nyazoom = {
script = /* bash */''
export DATABASE_URL="sqlite:///var/lib/nyazoom/data"
export DIST_DIR="${nyazoom}/dist"
${lib.getExe nyazoom}
'';
wantedBy = [ "network.target" ];
wants = [ "network.target" ];
};
permafrost.nginx.enable = lib.mkDefault true;
permafrost.acme.certDomains = lib.mkIf ACMEEnabled [ "nyazoom.zynh.me" ];
services.nginx.virtualHosts."nyazoom.zynh.me" = {
serverName = "nyazoom.zynh.me";
forceSSL = lib.mkIf ACMEEnabled true;
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
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;
'';
};
};
};
}