{ config, lib, pkgs, options, ... }: with lib; let cfg = config.modules.services.yugoslavia-best; in { options.modules.services.yugoslavia-best = { enable = mkOption { type = types.bool; default = false; }; domain = mkOption { type = types.str; default = "yugoslavia.best"; }; root = mkOption { type = types.str; default = "/var/www/yugoslavia.best"; }; }; config = mkIf cfg.enable { modules.services.staticSites."${cfg.domain}" = { dataDir = cfg.root; php = true; }; services = { nginx.virtualHosts."${cfg.domain}" = { locations."/modding-txts/" = { extraConfig = '' autoindex on; sub_filter ''; sub_filter
 ' ';
        		sub_filter 
' '; sub_filter '' ''; sub_filter '' '
'; sub_filter '
'; sub_filter
'
'; sub_filter_once off; ''; }; locations."/srb2kaddons/" = { extraConfig = '' autoindex on; alias /home/oatmealine/.srb2kart/firepit/; sub_filter ''; sub_filter
 ' ';
		        sub_filter 
' '; sub_filter '' ''; sub_filter '' '
'; sub_filter '
'; sub_filter
'
'; sub_filter_once off; ''; }; locations."/__special" = { extraConfig = '' internal; allow all; root ${cfg.root}/nginx/html/__special; ''; }; locations."= /__md_file" = { extraConfig = '' internal; allow all; add_header 'Vary' 'Accept'; # redefining add_header Strict-Transport-Security $hsts_header; add_header Referrer-Policy origin-when-cross-origin; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; sub_filter '$request_filename - yugoslavia.best'; sub_filter_once on; default_type text/html; alias ${cfg.root}/nginx/html/__special/md-renderer.html; ''; }; locations."~* \\.md" = { extraConfig = '' error_page 418 = /__md_file; add_header 'Vary' 'Accept'; # redefining add_header Strict-Transport-Security $hsts_header; add_header Referrer-Policy origin-when-cross-origin; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; if (!-f $request_filename) { break; } # if no "text/markdown" in "accept" header: # redirect to /__md_file to serve html renderer if ($http_accept !~* "text/markdown") { return 418; } ''; }; extraConfig = '' types { text/plain md; text/html html; text/plain txt; text/css css; application/javascript js; image/x-icon ico; image/png png; image/gif gif; } ''; }; }; }; }