68 lines
1.5 KiB
Nix
68 lines
1.5 KiB
Nix
{ hostName, inputs, lib, ... }:
|
|
|
|
let
|
|
hostConf = config.site.hosts.${hostName};
|
|
|
|
pppoeInterfaces =
|
|
lib.filterAttrs (_: { type, ... }: type == "pppoe")
|
|
hostConf.interfaces;
|
|
|
|
firstUpstreamInterface =
|
|
if builtins.length (builtins.attrNames upstreamInterfaces) > 0
|
|
then builtins.head (
|
|
builtins.attrNames upstreamInterfaces
|
|
)
|
|
else null;
|
|
|
|
inherit (inputs.zentralwerk-network-key.lib.pppoe.${hostName}) user password;
|
|
in lib.mkIf (pppoeInterfaces != {}) {
|
|
boot.postBootCommands = ''
|
|
if [ ! -c /dev/ppp ]; then
|
|
mknod -m 666 /dev/ppp c 108 0
|
|
fi
|
|
'';
|
|
|
|
environment.etc."ppp/pap-secrets".text = ''
|
|
"${user}" * "${password}"
|
|
'';
|
|
services.pppd = {
|
|
enable = true;
|
|
peers = builtins.mapAttrs (ifName: { upstream, ... }: {
|
|
enable = true;
|
|
autostart = true;
|
|
config = ''
|
|
plugin rp-pppoe.so
|
|
nic-${upstream.link}
|
|
ifname ${ifName}
|
|
# Login settings. (PAP)
|
|
name "${user}"
|
|
noauth
|
|
hide-password
|
|
# Connection settings.
|
|
persist
|
|
# Max connection attempts (0 = no limit)
|
|
maxfail 0
|
|
# Seconds between reconnection attempts
|
|
holdoff 1
|
|
|
|
# LCP settings.
|
|
lcp-echo-interval 5
|
|
lcp-echo-failure 6
|
|
|
|
# PPPoE compliant settings.
|
|
noaccomp
|
|
default-asyncmap
|
|
mtu 1492
|
|
# IP settings.
|
|
#noipdefault
|
|
defaultroute
|
|
+ipv6
|
|
defaultroute6
|
|
# Increase debugging level
|
|
debug
|
|
'';
|
|
};
|
|
};
|
|
|
|
}
|