diff --git a/modules/core/vhost.nix b/modules/core/vhost.nix index 42aa950..1de5305 100644 --- a/modules/core/vhost.nix +++ b/modules/core/vhost.nix @@ -73,6 +73,12 @@ in default = { }; description = "An attribute set of location configurations."; }; + + resolveLocally = mkOption { + type = types.bool; + default = true; + description = "If true, ensure the vhost is resolvable to 127.0.0.1 locally on this server."; + }; }; }); default = { }; @@ -114,5 +120,11 @@ in conf.locations; }) cfg.hosts; + + networking.extraHosts = concatMapStringsSep "\n" + (domain: + mkIf cfg.hosts.${domain}.resolveLocally "127.0.0.1 ${domain}" + ) + (lib.attrNames cfg.hosts); }; }