nixos/clatd: add enableNetworkManagerIntegration option
This commit is contained in:
@@ -13,6 +13,11 @@ in
|
||||
|
||||
package = lib.mkPackageOption pkgs "clatd" { };
|
||||
|
||||
enableNetworkManagerIntegration = lib.mkEnableOption "NetworkManager integration" // {
|
||||
default = config.networking.networkmanager.enable;
|
||||
defaultText = "config.networking.networkmanager.enable";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule ({ name, ... }: {
|
||||
freeformType = settingsFormat.type;
|
||||
@@ -75,5 +80,17 @@ in
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
networking.networkmanager.dispatcherScripts = cfg.enableNetworkManagerIntegration [
|
||||
{
|
||||
type = "basic";
|
||||
# https://github.com/toreanderson/clatd/blob/master/scripts/clatd.networkmanager
|
||||
source = pkgs.writeShellScript "restart-clatd" ''
|
||||
[ "$DEVICE_IFACE" = "clat" ] && exit 0
|
||||
[ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
|
||||
${pkgs.systemd}/bin/systemctl restart clatd.service
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user