DRY loopback interface, it's the same everywhere

This commit is contained in:
Daniel Barlow 2023-03-07 22:02:24 +00:00
parent 0436025e91
commit fec77a44b5
6 changed files with 30 additions and 73 deletions

View file

@ -24,28 +24,6 @@
inherit (pkgs) dropbear ifwait serviceFns inherit (pkgs) dropbear ifwait serviceFns
; ;
in rec { 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 = { boot = {
tftp = { tftp = {
enable = true; enable = true;
@ -177,17 +155,17 @@ in rec {
services.default = target { services.default = target {
name = "default"; name = "default";
contents = with services; [ contents =
loopback let links = config.hardware.networkInterfaces;
config.hardware.networkInterfaces.eth in with services; [
config.hardware.networkInterfaces.wlan links.lo links.eth links.wlan
int int
bridge bridge
hostap hostap
defaultroute4 defaultroute4
# resolvconf # resolvconf
sshd sshd
]; ];
}; };
defaultProfile.packages = with pkgs; [nftables strace tcpdump swconfig]; defaultProfile.packages = with pkgs; [nftables strace tcpdump swconfig];
} }

View file

@ -3,6 +3,8 @@ let
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
inherit (pkgs.pseudofile) dir symlink; inherit (pkgs.pseudofile) dir symlink;
inherit (pkgs) busybox; inherit (pkgs) busybox;
inherit (pkgs.liminix.networking) address interface;
inherit (pkgs.liminix.services) bundle;
type_service = types.package // { type_service = types.package // {
name = "service"; name = "service";
@ -46,6 +48,18 @@ in {
defaultProfile.packages = with pkgs; defaultProfile.packages = with pkgs;
[ s6 s6-init-bin busybox execline s6-linux-init s6-rc ]; [ 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 { kernel = rec {
config = { config = {
IKCONFIG = "y"; IKCONFIG = "y";

View file

@ -22,16 +22,6 @@ let
ifwait ifwait
serviceFns; serviceFns;
in rec { 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 = { boot = {
tftp = { tftp = {
enable = true; enable = true;
@ -221,7 +211,7 @@ in rec {
services.default = target { services.default = target {
name = "default"; name = "default";
contents = with services; [ contents = with services; [
loopback config.hardware.networkInterfaces.lo
config.hardware.networkInterfaces.lan config.hardware.networkInterfaces.lan
int int
bridge bridge

View file

@ -3,16 +3,6 @@ let
inherit (pkgs.liminix.networking) interface address pppoe route dnsmasq; inherit (pkgs.liminix.networking) interface address pppoe route dnsmasq;
inherit (pkgs.liminix.services) oneshot longrun bundle target output; inherit (pkgs.liminix.services) oneshot longrun bundle target output;
in rec { 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 = services.lan4 =
let iface = interface { type = "hardware"; device = "eth1";}; let iface = interface { type = "hardware"; device = "eth1";};
in address iface { family = "inet4"; address ="192.168.19.1"; prefixLength = 24;}; in address iface { family = "inet4"; address ="192.168.19.1"; prefixLength = 24;};
@ -75,7 +65,7 @@ in rec {
services.default = target { services.default = target {
name = "default"; name = "default";
contents = with services; [ contents = with services; [
loopback config.hardware.networkInterfaces.lo
defaultroute4 defaultroute4
packet_forwarding packet_forwarding
dns dns

View file

@ -3,15 +3,7 @@ let
inherit (pkgs.liminix.networking) interface address hostapd route dnsmasq; inherit (pkgs.liminix.networking) interface address hostapd route dnsmasq;
inherit (pkgs.liminix.services) oneshot longrun bundle target; inherit (pkgs.liminix.services) oneshot longrun bundle target;
in rec { in rec {
services.loopback = services.loopback = config.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;})
];
};
imports = [ ../../modules/wlan.nix ]; imports = [ ../../modules/wlan.nix ];

View file

@ -7,15 +7,8 @@ in rec {
./modules/tftpboot.nix ./modules/tftpboot.nix
./modules/wlan.nix ./modules/wlan.nix
]; ];
services.loopback = services.loopback = config.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;})
];
};
services.dhcpv4 = services.dhcpv4 =
let iface = interface { type = "hardware"; device = "eth0"; }; let iface = interface { type = "hardware"; device = "eth0"; };
in udhcpc iface {}; in udhcpc iface {};