2022-09-25 12:22:15 +02:00
|
|
|
{ config, pkgs, ... } :
|
2022-09-20 00:51:38 +02:00
|
|
|
let
|
2022-09-26 13:55:10 +02:00
|
|
|
inherit (pkgs.liminix.networking) interface address udhcpc odhcpc route;
|
2022-10-02 17:35:55 +02:00
|
|
|
inherit (pkgs.liminix.services) oneshot longrun bundle target;
|
2022-09-20 00:51:38 +02:00
|
|
|
in rec {
|
2023-02-11 14:10:38 +01:00
|
|
|
imports = [
|
|
|
|
./modules/phram.nix
|
|
|
|
];
|
2022-09-20 00:51:38 +02:00
|
|
|
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-20 00:51:38 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
services.dhcpv4 =
|
|
|
|
let iface = interface { type = "hardware"; device = "eth0"; };
|
|
|
|
in udhcpc iface {};
|
|
|
|
|
|
|
|
services.dhcpv6 =
|
|
|
|
let iface = interface { type = "hardware"; device = "eth0"; };
|
|
|
|
in odhcpc iface { uid = "e7"; };
|
|
|
|
|
|
|
|
services.ntp = longrun {
|
|
|
|
name = "ntp";
|
2022-09-20 16:46:03 +02:00
|
|
|
run = let inherit (services) dhcpv4 dhcpv6;
|
2022-10-02 17:35:55 +02:00
|
|
|
in "${pkgs.ntp}/bin/ntpd $(output ${dhcpv4} ntp_servers) $(output ${dhcpv6} NTP_IP})";
|
2022-09-20 16:46:03 +02:00
|
|
|
|
2022-09-20 00:51:38 +02:00
|
|
|
# I don't think it's possible to standardise the file names
|
|
|
|
# generally, as different services have different outputs, but it
|
|
|
|
# would be cool if services that provide an interface could use
|
|
|
|
# the same name as each other. e.g. for anything implementing
|
|
|
|
# addressProvider you might expect (output svc "address") or
|
|
|
|
# (output svc "family") to work. Otherwise switching a network link
|
|
|
|
# from static to dhcp might require reviewing all the downstreams
|
|
|
|
# that refer to it.
|
|
|
|
# Also, services should declare the outputs they provide
|
|
|
|
outputs = [];
|
|
|
|
dependencies = [services.dhcpv4];
|
|
|
|
};
|
|
|
|
|
2022-09-26 13:55:10 +02:00
|
|
|
services.defaultroute4 = route {
|
|
|
|
name = "defautlrote";
|
2022-10-02 17:35:55 +02:00
|
|
|
via = "$(output ${services.dhcpv4} address)";
|
2022-09-26 13:55:10 +02:00
|
|
|
target = "default";
|
|
|
|
dependencies = [ services.dhcpv4 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.packet_forwarding =
|
|
|
|
let
|
|
|
|
iface = services.dhcpv4;
|
2022-10-02 17:35:55 +02:00
|
|
|
filename = "/proc/sys/net/ipv4/conf/$(output ${iface} ifname)/forwarding";
|
2022-09-20 00:51:38 +02:00
|
|
|
in oneshot {
|
2022-09-26 13:55:10 +02:00
|
|
|
name = "let-the-ip-flow";
|
|
|
|
up = "echo 1 > ${filename}";
|
|
|
|
down = "echo 0 > ${filename}";
|
|
|
|
dependencies = [iface];
|
2022-09-20 00:51:38 +02:00
|
|
|
};
|
2022-09-22 01:10:55 +02:00
|
|
|
|
|
|
|
services.default = target {
|
|
|
|
name = "default";
|
|
|
|
contents = with services; [ loopback ntp defaultroute4 ];
|
|
|
|
};
|
|
|
|
|
2022-09-27 17:17:55 +02:00
|
|
|
defaultProfile.packages = [ pkgs.hello ] ;
|
2022-09-20 00:51:38 +02:00
|
|
|
}
|