From 28424ccb86f9fe02c9e9f95958cf10d3a9fe3777 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 27 Dec 2024 13:16:07 +0100 Subject: refactor: split up tente/default.nix --- nixos/hosts/tente/web-personal.nix | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 nixos/hosts/tente/web-personal.nix (limited to 'nixos/hosts/tente/web-personal.nix') diff --git a/nixos/hosts/tente/web-personal.nix b/nixos/hosts/tente/web-personal.nix new file mode 100644 index 0000000..7c17063 --- /dev/null +++ b/nixos/hosts/tente/web-personal.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.web-personal; +in +{ + options.web-personal = { + domain = lib.mkOption { + type = lib.types.str; + }; + matrixApiDomain = lib.mkOption { + type = lib.types.str; + }; + }; + + config = { + services = { + nginx.virtualHosts.${cfg.domain} = + let + mkWellKnown = data: '' + default_type application/json; + add_header Access-Control-Allow-Origin *; + return 200 '${builtins.toJSON data}'; + ''; + in + { + enableACME = true; + forceSSL = true; + root = "/srv/www/${cfg.domain}"; + + locations."= /.well-known/matrix/server".extraConfig = mkWellKnown { + "m.server" = "${cfg.matrixApiDomain}:443"; + }; + locations."= /.well-known/matrix/client".extraConfig = mkWellKnown { + "m.homeserver" = { base_url = "https://${cfg.matrixApiDomain}"; }; + }; + }; + }; + }; +} -- cgit v1.2.3