diff --git a/extneder.nix b/extneder.nix index 7c5a57c..b651c03 100644 --- a/extneder.nix +++ b/extneder.nix @@ -24,28 +24,6 @@ inherit (pkgs) dropbear ifwait serviceFns ; in rec { - services.loopback = let - iface = interface { - type = "loopback"; - device = "lo"; - }; - in - bundle { - name = "loopback"; - contents = [ - (address iface { - family = "inet4"; - address = "127.0.0.1"; - prefixLength = 8; - }) - (address iface { - family = "inet6"; - address = "::1"; - prefixLength = 128; - }) - ]; - }; - boot = { tftp = { enable = true; @@ -177,17 +155,17 @@ in rec { services.default = target { name = "default"; - contents = with services; [ - loopback - config.hardware.networkInterfaces.eth - config.hardware.networkInterfaces.wlan - int - bridge - hostap - defaultroute4 - # resolvconf - sshd - ]; + contents = + let links = config.hardware.networkInterfaces; + in with services; [ + links.lo links.eth links.wlan + int + bridge + hostap + defaultroute4 + # resolvconf + sshd + ]; }; defaultProfile.packages = with pkgs; [nftables strace tcpdump swconfig]; } diff --git a/modules/base.nix b/modules/base.nix index e0b8656..ed8811b 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -3,6 +3,8 @@ let inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; inherit (pkgs.pseudofile) dir symlink; inherit (pkgs) busybox; + inherit (pkgs.liminix.networking) address interface; + inherit (pkgs.liminix.services) bundle; type_service = types.package // { name = "service"; @@ -46,6 +48,18 @@ in { defaultProfile.packages = with pkgs; [ s6 s6-init-bin busybox execline s6-linux-init s6-rc ]; + hardware.networkInterfaces = { + lo = + let iface = interface { type = "loopback"; device = "lo";}; + in bundle { + name = "loopback"; + contents = [ + (address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;}) + (address iface { family = "inet6"; address ="::1"; prefixLength = 128;}) + ]; + }; + }; + kernel = rec { config = { IKCONFIG = "y"; diff --git a/rotuer.nix b/rotuer.nix index 660d5e6..e777a64 100644 --- a/rotuer.nix +++ b/rotuer.nix @@ -22,16 +22,6 @@ let ifwait serviceFns; in rec { - services.loopback = - let iface = interface { type = "loopback"; device = "lo";}; - in bundle { - name = "loopback"; - contents = [ - (address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;}) - (address iface { family = "inet6"; address ="::1"; prefixLength = 128;}) - ]; - }; - boot = { tftp = { enable = true; @@ -221,7 +211,7 @@ in rec { services.default = target { name = "default"; contents = with services; [ - loopback + config.hardware.networkInterfaces.lo config.hardware.networkInterfaces.lan int bridge diff --git a/tests/pppoe/configuration.nix b/tests/pppoe/configuration.nix index c6fa632..c9601ae 100644 --- a/tests/pppoe/configuration.nix +++ b/tests/pppoe/configuration.nix @@ -3,16 +3,6 @@ let inherit (pkgs.liminix.networking) interface address pppoe route dnsmasq; 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 = [ - (address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;}) - (address iface { family = "inet6"; address ="::1"; prefixLength = 128;}) - ]; - }; - services.lan4 = let iface = interface { type = "hardware"; device = "eth1";}; in address iface { family = "inet4"; address ="192.168.19.1"; prefixLength = 24;}; @@ -75,7 +65,7 @@ in rec { services.default = target { name = "default"; contents = with services; [ - loopback + config.hardware.networkInterfaces.lo defaultroute4 packet_forwarding dns diff --git a/tests/wlan/configuration.nix b/tests/wlan/configuration.nix index 91300ae..1148e4d 100644 --- a/tests/wlan/configuration.nix +++ b/tests/wlan/configuration.nix @@ -3,15 +3,7 @@ let inherit (pkgs.liminix.networking) interface address hostapd route dnsmasq; inherit (pkgs.liminix.services) oneshot longrun bundle target; in rec { - services.loopback = - let iface = interface { type = "loopback"; device = "lo";}; - in bundle { - name = "loopback"; - contents = [ - (address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;}) - (address iface { family = "inet6"; address ="::1"; prefixLength = 128;}) - ]; - }; + services.loopback = config.hardware.networkInterfaces.lo; imports = [ ../../modules/wlan.nix ]; diff --git a/vanilla-configuration.nix b/vanilla-configuration.nix index e37fbff..1b88f63 100644 --- a/vanilla-configuration.nix +++ b/vanilla-configuration.nix @@ -7,15 +7,8 @@ in rec { ./modules/tftpboot.nix ./modules/wlan.nix ]; - services.loopback = - let iface = interface { type = "loopback"; device = "lo";}; - in bundle { - name = "loopback"; - contents = [ - (address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;}) - (address iface { family = "inet6"; address ="::1"; prefixLength = 128;}) - ]; - }; + services.loopback = config.hardware.networkInterfaces.lo; + services.dhcpv4 = let iface = interface { type = "hardware"; device = "eth0"; }; in udhcpc iface {};