define vpn container hosts within containers too
This commit is contained in:
@@ -153,6 +153,13 @@ in
|
|||||||
description = "Prefix length derived from subnet CIDR";
|
description = "Prefix length derived from subnet CIDR";
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Shared host entries for all containers (host + VPN + service containers)
|
||||||
|
containerHosts = mkOption {
|
||||||
|
type = types.attrsOf (types.listOf types.str);
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@@ -252,10 +259,12 @@ in
|
|||||||
# Host entries for container hostnames — NixOS only auto-creates these for
|
# Host entries for container hostnames — NixOS only auto-creates these for
|
||||||
# hostAddress/localAddress containers, not hostBridge. Use the standard
|
# hostAddress/localAddress containers, not hostBridge. Use the standard
|
||||||
# {name}.containers convention.
|
# {name}.containers convention.
|
||||||
networking.hosts =
|
pia-vpn.containerHosts =
|
||||||
{ ${cfg.vpnAddress} = [ "pia-vpn.containers" ]; }
|
{ ${cfg.vpnAddress} = [ "pia-vpn.containers" ]; }
|
||||||
// mapAttrs' (name: ctr: nameValuePair ctr.ip [ "${name}.containers" ]) cfg.containers;
|
// mapAttrs' (name: ctr: nameValuePair ctr.ip [ "${name}.containers" ]) cfg.containers;
|
||||||
|
|
||||||
|
networking.hosts = cfg.containerHosts;
|
||||||
|
|
||||||
# PIA login secret
|
# PIA login secret
|
||||||
age.secrets."pia-login.conf".file = ../../../secrets/pia-login.age;
|
age.secrets."pia-login.conf".file = ../../../secrets/pia-login.age;
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.hosts = cfg.containerHosts;
|
||||||
|
|
||||||
# DNS through VPN container (queries go through WG tunnel = no DNS leak)
|
# DNS through VPN container (queries go through WG tunnel = no DNS leak)
|
||||||
networking.nameservers = [ cfg.vpnAddress ];
|
networking.nameservers = [ cfg.vpnAddress ];
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ in
|
|||||||
{
|
{
|
||||||
imports = allModules;
|
imports = allModules;
|
||||||
|
|
||||||
|
networking.hosts = cfg.containerHosts;
|
||||||
|
|
||||||
# Static IP on bridge — no gateway (VPN container routes via WG only)
|
# Static IP on bridge — no gateway (VPN container routes via WG only)
|
||||||
networking.useNetworkd = true;
|
networking.useNetworkd = true;
|
||||||
systemd.network.enable = true;
|
systemd.network.enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user