12 cfg = config.services.networkd-dispatcher;
18 services.networkd-dispatcher = {
20 enable = mkEnableOption ''
21 Networkd-dispatcher service for systemd-networkd connection status
22 change. See [upstream instructions](https://gitlab.com/craftyguy/networkd-dispatcher)
28 example = lib.literalExpression ''
30 onState = ["routable" "off"];
32 #!''${pkgs.runtimeShell}
33 if [[ $IFACE == "wlan0" && $AdministrativeState == "configured" ]]; then
34 echo "Restarting Tor ..."
43 Declarative configuration of networkd-dispatcher rules. See
44 [upstream instructions](https://gitlab.com/craftyguy/networkd-dispatcher)
45 for an introduction and example scripts.
47 type = types.attrsOf (
65 List of names of the systemd-networkd operational states which
66 should trigger the script. See <https://www.freedesktop.org/software/systemd/man/networkctl.html>
67 for a description of the specific state type.
73 Shell commands executed on specified operational states.
81 extraArgs = mkOption {
82 type = types.listOf types.str;
85 Extra arguments to pass to the networkd-dispatcher command.
87 apply = escapeShellArgs;
93 config = mkIf cfg.enable {
96 packages = [ pkgs.networkd-dispatcher ];
97 services.networkd-dispatcher = {
98 wantedBy = [ "multi-user.target" ];
99 environment.networkd_dispatcher_args = cfg.extraArgs;
103 services.networkd-dispatcher.extraArgs =
105 scriptDir = pkgs.symlinkJoin {
106 name = "networkd-dispatcher-script-dir";
107 paths = lib.mapAttrsToList (
114 destination = "/${state}.d/${name}";