diff options
Diffstat (limited to 'config/networking/services')
| -rw-r--r-- | config/networking/services/default.nix | 7 | ||||
| -rw-r--r-- | config/networking/services/ifplugd.nix | 37 |
2 files changed, 39 insertions, 5 deletions
diff --git a/config/networking/services/default.nix b/config/networking/services/default.nix index 0ec9540..623a1c7 100644 --- a/config/networking/services/default.nix +++ b/config/networking/services/default.nix @@ -1,6 +1,3 @@ -{ ... }: - -{ - imports = - [ ./ap.nix ./dhcp.nix ./dns.nix ./firewall ./igmpproxy.nix ]; +{...}: { + imports = [./ap.nix ./dhcp.nix ./dns.nix ./firewall ./ifplugd.nix ./igmpproxy.nix]; } diff --git a/config/networking/services/ifplugd.nix b/config/networking/services/ifplugd.nix new file mode 100644 index 0000000..4933b97 --- /dev/null +++ b/config/networking/services/ifplugd.nix @@ -0,0 +1,37 @@ +{ + config, + pkgs, + ... +}: let + iface = config.personal.networking.networks.eth0.device; + dhcpService = "kea-dhcp4-server.service"; + action = pkgs.writeShellApplication { + name = "ifplugd-enp3s0.action"; + runtimeInputs = [pkgs.systemd]; + text = '' + INTERFACE="$1" + EVENT="$2" + + if [[ "$INTERFACE" == '${iface}' && "$EVENT" == up ]] + then + echo ${iface} went up, restarting ${dhcpService}... + systemctl restart ${dhcpService} + fi + ''; + }; +in { + systemd.services."ifplugd-${iface}" = { + enable = true; + + description = "Monitor status of interface ${iface}"; + after = ["sys-subsystem-net-devices-${iface}.device" dhcpService]; + wantedBy = [dhcpService]; + + script = '' + # iface no-daemon no-auto no-shutdown delay-up run + ifplugd -i ${iface} -n -a -q -u 5 -r \ + ${action}/bin/ifplugd-enp3s0.action + ''; + path = [pkgs.busybox]; + }; +} |
