I want to run a script when a network interface goes down. If it losses it ethernet carrier, either thru having the cable disconnected or an directly attached ethernet switch failure (power).
A normal linux system , you could place a script in /etc/network/if-down.d/ and you’d be good to go.
or wrangle head to head with the beast that is systemd.
https://andreas.scherbaum.la/blog/archives/963-if-up-and-if-down-scripts-with-systemd.html
However , how would i approach this in nixos? i see there is a few systemd targets.
systemctl | grep network
network-addresses-enp0s25.service loaded active exited Address configuration of enp0s25
network-link-enp0s25.service loaded active exited Link configuration of enp0s25
network-local-commands.service loaded active exited Extra networking commands.
network-setup.service loaded active exited Networking Setup
network-interfaces.target loaded active active All Network Interfaces (deprecated)
network-online.target loaded active active Network is Online
network-pre.target loaded active active Network (Pre)
network.target loaded active active Network
How would one approach this in the Nixos way?