2022-09-25 12:54:31 +02:00
|
|
|
{ config, pkgs, ... } :
|
|
|
|
let
|
|
|
|
inherit (pkgs.liminix.networking) interface address pppoe;
|
|
|
|
inherit (pkgs.liminix.services) oneshot longrun bundle target output;
|
|
|
|
in rec {
|
|
|
|
services.loopback =
|
|
|
|
let iface = interface { type = "loopback"; device = "lo";};
|
|
|
|
in bundle {
|
|
|
|
name = "loopback";
|
|
|
|
contents = [
|
2022-09-25 17:51:13 +02:00
|
|
|
(address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;})
|
|
|
|
(address iface { family = "inet6"; address ="::1"; prefixLength = 128;})
|
2022-09-25 12:54:31 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
kernel.config = {
|
2022-09-25 22:12:23 +02:00
|
|
|
"IKCONFIG_PROC" = "y";
|
2022-09-25 12:54:31 +02:00
|
|
|
"PPP" = "y";
|
|
|
|
"PPPOE" = "y";
|
|
|
|
"PPPOL2TP" = "y";
|
2022-09-25 22:12:23 +02:00
|
|
|
"PPP_ASYNC" = "y";
|
|
|
|
"PPP_BSDCOMP" = "y";
|
|
|
|
"PPP_DEFLATE" = "y";
|
|
|
|
"PPP_MPPE" = "y";
|
|
|
|
"PPP_SYNC_TTY" = "y";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.syslogd = longrun {
|
|
|
|
name = "syslogd";
|
|
|
|
run = "${pkgs.busybox}/bin/syslogd -n -O /run/syslog";
|
2022-09-25 12:54:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.pppoe =
|
|
|
|
let iface = interface { type = "hardware"; device = "eth0"; };
|
2022-09-25 22:12:23 +02:00
|
|
|
in pppoe iface {
|
|
|
|
ppp-options = [
|
|
|
|
"debug" "+ipv6" "noauth"
|
|
|
|
"name" "db123@a.1"
|
|
|
|
"password" "NotReallyTheSecret"
|
|
|
|
];
|
|
|
|
};
|
2022-09-25 12:54:31 +02:00
|
|
|
|
|
|
|
services.defaultroute4 =
|
|
|
|
let iface = services.pppoe;
|
|
|
|
in oneshot {
|
|
|
|
name = "defaultroute4";
|
|
|
|
up = ''
|
2022-09-25 22:12:23 +02:00
|
|
|
ip route add default via $(cat ${output iface "address"})
|
|
|
|
echo "1" > /proc/sys/net/ipv4/conf/$(cat ${output iface "ifname"}/forwarding)
|
2022-09-25 12:54:31 +02:00
|
|
|
'';
|
|
|
|
down = ''
|
2022-09-25 22:12:23 +02:00
|
|
|
ip route del default via $(cat ${output iface "address"})
|
|
|
|
echo "0" > /proc/sys/net/ipv4/conf/$(cat ${output iface "ifname"}/forwarding)
|
2022-09-25 12:54:31 +02:00
|
|
|
'';
|
|
|
|
dependencies = [iface];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.default = target {
|
|
|
|
name = "default";
|
2022-09-25 22:12:23 +02:00
|
|
|
contents = with services; [ loopback defaultroute4 syslogd ];
|
2022-09-25 12:54:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
systemPackages = [ pkgs.hello ] ;
|
|
|
|
}
|