refactor: simplify DNS configuration for vhosts with dynamic interface detection
This commit is contained in:
parent
301629243e
commit
1a54c00cc2
@ -13,8 +13,7 @@
|
||||
};
|
||||
|
||||
# Configure AdGuard
|
||||
pepe.core.vhost.hosts."adguard.giugl.io" = with config.pepe.core.network; {
|
||||
dnsInterfaces = [ interfacesByType.vpn interfacesByType.lan ];
|
||||
pepe.core.vhost.hosts."adguard.giugl.io" = {
|
||||
locations."/" = {
|
||||
port = config.services.adguardhome.port;
|
||||
allowLAN = true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types mapAttrs concatMapStringsSep optionalString;
|
||||
inherit (lib) mkOption types mapAttrs concatMapStringsSep optionalString mkIf;
|
||||
cfg = config.pepe.core.vhost;
|
||||
in
|
||||
{
|
||||
@ -9,13 +9,6 @@ in
|
||||
hosts = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
dnsInterfaces = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "List of interfaces to add extra DNS hosts for this vhost.";
|
||||
example = "config.pepe.core.network.interfaceTypes.lan";
|
||||
};
|
||||
|
||||
locations = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
@ -88,6 +81,17 @@ in
|
||||
};
|
||||
|
||||
config = {
|
||||
# Configure DNS entries for vhosts when DNS is enabled
|
||||
pepe.core.dns = mkIf config.pepe.core.dns.enable {
|
||||
extraDomains = mapAttrs (domain: conf: {
|
||||
dnsInterfaces =
|
||||
(lib.optionals (lib.any (loc: loc.allowLAN) (lib.attrValues conf.locations))
|
||||
config.pepe.core.network.interfacesByType.lan) ++
|
||||
(lib.optionals (lib.any (loc: loc.allowVPN) (lib.attrValues conf.locations))
|
||||
config.pepe.core.network.interfacesByType.vpn);
|
||||
}) cfg.hosts;
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = mapAttrs
|
||||
(domain: conf: {
|
||||
forceSSL = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user