diff --git a/hosts/vm.strangervm.ts.hillion.co.uk/default.nix b/hosts/vm.strangervm.ts.hillion.co.uk/default.nix index 5d9319f..e3c5e39 100644 --- a/hosts/vm.strangervm.ts.hillion.co.uk/default.nix +++ b/hosts/vm.strangervm.ts.hillion.co.uk/default.nix @@ -20,6 +20,7 @@ ## Custom Services custom = { + locations.autoServe = true; www.global.enable = true; services.matrix.enable = true; }; diff --git a/modules/default.nix b/modules/default.nix index acd60a0..846f9b8 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,6 +4,7 @@ imports = [ ./backups/default.nix ./desktop/awesome/default.nix + ./locations.nix ./resilio.nix ./services/matrix.nix ./tailscale.nix diff --git a/modules/locations.nix b/modules/locations.nix new file mode 100644 index 0000000..77748a2 --- /dev/null +++ b/modules/locations.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: + +let + cfg = config.custom.locations; +in +{ + options.custom.locations = { + autoServe = lib.mkOption { + default = false; + type = lib.types.bool; + }; + + locations = lib.mkOption { + default = { + services = { + matrix = "vm.strangervm.ts.hillion.co.uk"; + }; + }; + }; + }; + + config = lib.mkIf cfg.autoServe { + custom.services.matrix.enable = cfg.locations.services.matrix == config.networking.fqdn; + }; +} diff --git a/modules/www/global.nix b/modules/www/global.nix index 1b318a3..6016271 100644 --- a/modules/www/global.nix +++ b/modules/www/global.nix @@ -2,6 +2,7 @@ let cfg = config.custom.www.global; + locations = config.custom.locations.locations; in { options.custom.www.global = { @@ -39,7 +40,7 @@ in reverse_proxy http://plex.mediaserver.ts.hillion.co.uk:8096 ''; virtualHosts."matrix.hillion.co.uk".extraConfig = '' - reverse_proxy http://vm.strangervm.ts.hillion.co.uk:8008 + reverse_proxy http://${locations.services.matrix}:8008 ''; virtualHosts."unifi.hillion.co.uk".extraConfig = '' reverse_proxy https://unifi.unifi.ts.hillion.co.uk:8443 {