1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

networking: Add wakeOnLan option

This commit is contained in:
Philip Børgesen 2023-11-18 14:18:06 +01:00
parent 5f05c2c3d2
commit 5907cbbb31
2 changed files with 26 additions and 0 deletions

View file

@ -9,6 +9,8 @@ let
emptyList = lst: if lst != [] then lst else ["empty"]; emptyList = lst: if lst != [] then lst else ["empty"];
onOff = cond: if cond then "on" else "off";
setNetworkServices = optionalString (cfg.knownNetworkServices != []) '' setNetworkServices = optionalString (cfg.knownNetworkServices != []) ''
networkservices=$(networksetup -listallnetworkservices) networkservices=$(networksetup -listallnetworkservices)
${concatMapStringsSep "\n" (srv: '' ${concatMapStringsSep "\n" (srv: ''
@ -93,6 +95,16 @@ in
default = []; default = [];
description = "The list of search paths used when resolving domain names."; description = "The list of search paths used when resolving domain names.";
}; };
networking.wakeOnLan.enable = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
Enable Wake-on-LAN for the device.
Battery powered devices may require being connected to power.
'';
};
}; };
config = { config = {
@ -116,6 +128,10 @@ in
''} ''}
${setNetworkServices} ${setNetworkServices}
${optionalString (cfg.wakeOnLan.enable != null) ''
systemsetup -setWakeOnNetworkAccess '${onOff cfg.wakeOnLan.enable}' &> /dev/null
''}
''; '';
}; };

View file

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
{
networking.wakeOnLan.enable = true;
test = ''
echo checking wake on network access settings in /activate >&2
grep "systemsetup -setWakeOnNetworkAccess 'on'" ${config.out}/activate
'';
}