SUJ7TKWXHFZCEEQFGLRT4PZ4TYAXFLNDZVE57SN2AHXTLEPX7WXAC { self, config, lib, pkgs, ... }: letinherit (config.networking) domain;inherit (lib) enabled;fqdn = "chat.${domain}";in {imports = [(self + /modules/nginx.nix)];# cinny web client configurationservices.nginx.virtualHosts.${fqdn} = lib.merge config.services.nginx.sslTemplate {root = pkgs.cinny;# serve custom config.jsonlocations."= /config.json".extraConfig = ''default_type application/json;return 200 '${builtins.toJSON {defaultHomeserver = 0;homeserverList = [ "matrix.${domain}" ];allowCustomHomeservers = false;hashRouter = {enabled = false;};}}';'';extraConfig = /* nginx */ ''rewrite ^/config.json$ /config.json break;rewrite ^/manifest.json$ /manifest.json break;rewrite ^/sw.js$ /sw.js break;rewrite ^/pdf.worker.min.js$ /pdf.worker.min.js break;rewrite ^/public/(.*)$ /public/$1 break;rewrite ^/assets/(.*)$ /assets/$1 break;rewrite ^(.+)$ /index.html break;'';# static assets cachinglocations."~* \\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$" = {extraConfig = ''expires 1y;'';};};}
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' ${domain} *.${domain}; object-src 'self' ${domain} *.${domain}; base-uri 'self';" always;
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' ${domain} *.${domain}; object-src 'self' ${domain} *.${domain}; base-uri 'self'; frame-ancestors 'self';" always;
# SECURITY: Additional 2024 security headersproxy_hide_header X-Content-Type-Options;add_header X-Content-Type-Options nosniff always;proxy_hide_header X-XSS-Protection;add_header X-XSS-Protection "1; mode=block" always;proxy_hide_header Permissions-Policy;add_header Permissions-Policy "camera=(), geolocation=(), payment=(), usb=()" always;
timerConfig = {OnCalendar = "daily";Persistent = true;};
timerConfig.OnCalendar = "daily";timerConfig.Persistent = true;};systemd.services.matrix-synapse.serviceConfig = {# sandboxingPrivateTmp = true;ProtectSystem = "strict";ProtectHome = true;# fs restrictionsReadWritePaths = [ "/var/lib/matrix-synapse" ];# network restrictionsRestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];# miscNoNewPrivileges = true;RestrictSUIDSGID = true;
{ self, config, lib, pkgs, ... }: letinherit (config.networking) domain;fqdn = "chat.${domain}";in {imports = [ (self + /modules/nginx.nix) ];services.nginx.virtualHosts.${fqdn} = lib.merge config.services.nginx.sslTemplate {root = pkgs.element-web;locations."= /config.json".extraConfig = ''default_type application/json;return 200 '${builtins.toJSON {default_server_config."m.homeserver" = {base_url = "https://matrix.${domain}";server_name = domain;};brand = "chat.plumj.am";disable_3pid_login = true;disable_login_language_selector = true;disable_guests = true;bug_report_endpoint_url = null;show_labs_settings = true;features = {feature_pinning = "labs";feature_custom_status = "labs";feature_custom_tags = "labs";feature_state_counters = "labs";};default_federate = true;default_theme = "light";room_directory.servers = [ domain "matrix.org" ];enable_presence_by_hs_url = {"https://matrix.org" = false;"https://matrix-client.matrix.org" = false;};setting_defaults.breadcrumbs = true;}}';'';# spa routing serves index.html for all routeslocations."/".tryFiles = "$uri $uri/ /index.html";# static assets cachinglocations."~* \\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$".extraConfig = ''expires 1y;'';};}