feat: Add local vhost resolution via extraHosts

This commit is contained in:
Giulio De Pasquale (aider) 2025-06-05 12:50:30 +01:00
parent 44af2887a5
commit 7217af2233

View File

@ -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);
};
}