{ config, lib, pkgs, ... }: let cfg = config.profile.services.nginx; inherit (lib) mkIf attrsets strings lists ; in { config = mkIf cfg.enable { services.nginx = { enable = true; additionalModules = [ pkgs.nginxModules.pam ]; recommendedTlsSettings = true; recommendedGzipSettings = true; recommendedOptimisation = true; recommendedProxySettings = true; recommendedZstdSettings = true; recommendedBrotliSettings = true; enableReload = true; }; users.users.nginx.extraGroups = [ "acme" ]; security.acme = { acceptTerms = true; defaults.email = "tigor.hutasuhut@gmail.com"; }; # Enable Basic Authentication via PAM security.pam.services.nginx.setEnvironment = false; systemd.services.nginx.serviceConfig = { SupplementaryGroups = [ "shadow" ]; }; environment.etc."nginx/static/tigor.web.id/index.html" = { text = let domains = attrsets.mapAttrsToList ( name: _: strings.removePrefix "https://" name ) config.services.nginx.virtualHosts; sortedDomains = lists.sort (a: b: a < b) domains; list = map ( domain: # html ''
'') sortedDomains; items = strings.concatStringsSep "\n" list; in # html ''