nix-config/hosts/elisabeth/net.nix

105 lines
3.2 KiB
Nix
Raw Normal View History

2024-07-26 22:12:48 +02:00
{ config, lib, ... }:
{
networking = {
inherit (config.secrets.secrets.local.networking) hostId;
};
systemd.network.networks = {
2024-01-13 16:07:55 +01:00
"10-lan01" = {
2024-07-26 22:12:48 +02:00
address = [
(lib.net.cidr.hostCidr config.secrets.secrets.global.net.ips.${config.node.name}
config.secrets.secrets.global.net.privateSubnetv4
)
];
gateway = [ (lib.net.cidr.host 1 config.secrets.secrets.global.net.privateSubnetv4) ];
#matchConfig.MACAddress = config.secrets.secrets.local.networking.interfaces.lan01.mac;
matchConfig.Name = "lan";
2024-02-10 17:53:16 +01:00
dhcpV6Config.UseDNS = false;
dhcpV4Config.UseDNS = false;
2024-02-11 00:40:30 +01:00
ipv6AcceptRAConfig.UseDNS = false;
networkConfig = {
2024-04-02 23:33:22 +02:00
MulticastDNS = true;
};
};
"40-lan01" = {
dhcpV6Config.UseDNS = false;
dhcpV4Config.UseDNS = false;
ipv6AcceptRAConfig.UseDNS = false;
networkConfig = {
MulticastDNS = true;
};
};
};
boot.initrd.systemd.network = {
enable = true;
networks = {
# redo the network cause the livesystem has macvlans
2024-01-13 16:07:55 +01:00
"10-lan01" = {
2024-07-26 22:12:48 +02:00
address = [
(lib.net.cidr.hostCidr config.secrets.secrets.global.net.ips.${config.node.name}
config.secrets.secrets.global.net.privateSubnetv4
)
];
gateway = [ (lib.net.cidr.host 1 config.secrets.secrets.global.net.privateSubnetv4) ];
matchConfig.MACAddress = config.secrets.secrets.local.networking.interfaces.lan01.mac;
2024-02-10 17:53:16 +01:00
dhcpV6Config.UseDNS = false;
dhcpV4Config.UseDNS = false;
2024-04-02 23:33:22 +02:00
ipv6AcceptRAConfig.UseDNS = false;
networkConfig = {
IPv6PrivacyExtensions = "yes";
MulticastDNS = true;
};
};
};
};
2024-07-26 22:12:48 +02:00
networking.nftables.firewall.zones.untrusted.interfaces = [ "lan" ];
2024-03-14 23:08:42 +01:00
wireguard.elisabeth.server = {
2024-07-26 22:12:48 +02:00
host =
lib.net.cidr.host config.secrets.secrets.global.net.ips.${config.node.name}
config.secrets.secrets.global.net.privateSubnetv4;
reservedAddresses = [
"10.42.0.0/20"
"fd00:1764::/112"
];
2024-03-14 23:08:42 +01:00
openFirewall = true;
};
# To be able to ping containers from the host, it is necessary
# to create a macvlan on the host on the VLAN 1 network.
networking.macvlans.lan = {
interface = "lan01";
mode = "bridge";
};
2024-01-27 23:21:42 +01:00
age.secrets.cloudflare_token_acme = {
rekeyFile = ./secrets/cloudflare_api_token.age;
mode = "440";
group = "acme";
};
security.acme = {
acceptTerms = true;
defaults = {
email = config.secrets.secrets.global.devEmail;
dnsProvider = "cloudflare";
dnsPropagationCheck = true;
2024-07-26 22:12:48 +02:00
reloadServices = [ "nginx" ];
2024-01-27 23:21:42 +01:00
credentialFiles = {
"CF_DNS_API_TOKEN_FILE" = config.age.secrets.cloudflare_token_acme.path;
"CF_ZONE_API_TOKEN_FILE" = config.age.secrets.cloudflare_token_acme.path;
};
};
};
security.acme.certs.web = {
domain = config.secrets.secrets.global.domains.web;
2024-07-26 22:12:48 +02:00
extraDomainNames = [ "*.${config.secrets.secrets.global.domains.web}" ];
2024-01-27 23:21:42 +01:00
};
2024-07-26 22:12:48 +02:00
users.groups.acme.members = [ "nginx" ];
2024-01-27 23:21:42 +01:00
environment.persistence."/state".directories = [
{
directory = "/var/lib/acme";
user = "acme";
group = "acme";
mode = "0755";
}
];
}