feat: setup nginx and aiostreams for self-hosting

This commit is contained in:
tux
2026-06-30 17:03:21 +05:30
parent 9dec834633
commit 117a9f0807
3 changed files with 151 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
{
flake.modules.nixos.services =
{
config,
lib,
userEmail,
...
}:
with lib;
let
cfg = config.tnix.services.nginx;
in
{
options.tnix.services.nginx = {
enable = mkEnableOption "Enable Nginx";
domain = mkOption {
type = types.str;
default = "";
};
};
config = mkIf cfg.enable {
security = {
acme = {
acceptTerms = true;
defaults.email = "${userEmail}";
certs = {
"${cfg.domain}" = {
group = "nginx";
domain = "*.${cfg.domain}";
extraDomainNames = [ "${cfg.domain}" ];
dnsProvider = "cloudflare";
credentialFiles = {
CLOUDFLARE_EMAIL_FILE = config.sops.secrets."cloudflare-credentials/email".path;
CLOUDFLARE_DNS_API_TOKEN_FILE = config.sops.secrets."cloudflare-credentials/dns-api-token".path;
};
};
};
};
};
users.users.nginx.extraGroups = [ "acme" ];
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
};
};
};
}