dotfiles/modules/nixos/services/sunshine/default.nix
alejandro-angulo 3edb267414
Some checks failed
Buill NixOS Configurations / build (carbon) (push) Has been cancelled
Buill NixOS Configurations / build (git) (push) Has been cancelled
Buill NixOS Configurations / build (gospel) (push) Has been cancelled
Buill NixOS Configurations / build (node) (push) Has been cancelled
Ran nixfmt-tree
2026-02-28 21:25:59 -08:00

51 lines
1.2 KiB
Nix

{
config,
lib,
namespace,
...
}:
let
cfg = config."${namespace}".services.sunshine;
in
{
options."${namespace}".services.sunshine = with lib; {
enable = mkEnableOption "sunshine";
acmeCertName = mkOption {
type = types.str;
default = "";
description = ''
If set to a non-empty string, forces SSL with the supplied acme
certificate.
'';
};
};
config = lib.mkIf cfg.enable {
# NOTE: Navigate to localhost:47990 for first time configuration
services.sunshine = {
enable = true;
openFirewall = true;
};
services.nginx = {
enable = true;
virtualHosts."sunshine.kilonull.com" = {
locations."/" = {
recommendedProxySettings = true;
# NOTE: Sunshine is a little weird since it requires multiple
# ports. You configure it with a base port and the web UI +1 from
# the base port.
proxyPass = "https://127.0.0.1:${toString (config.services.sunshine.settings.port + 1)}";
extraConfig = ''
proxy_ssl_verify off;
'';
};
}
// lib.optionalAttrs (cfg.acmeCertName != "") {
forceSSL = true;
useACMEHost = cfg.acmeCertName;
};
};
};
}