From def1e23be848848400d1d097d4f044e3c401f9dd Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:02:32 +0200 Subject: treewide: remove lib.mdDoc --- modules/networking/default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'modules/networking') diff --git a/modules/networking/default.nix b/modules/networking/default.nix index c70b07d..1065c26 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -29,7 +29,7 @@ in type = types.nullOr types.str; default = null; example = "John’s MacBook Pro"; - description = lib.mdDoc '' + description = '' The user-friendly name for the system, set in System Preferences > Sharing > Computer Name. Setting this option is equivalent to running `scutil --set ComputerName`. @@ -42,7 +42,7 @@ in type = types.nullOr (types.strMatching hostnameRegEx); default = null; example = "Johns-MacBook-Pro"; - description = lib.mdDoc '' + description = '' The hostname of your system, as visible from the command line and used by local and remote networks when connecting through SSH and Remote Login. @@ -56,7 +56,7 @@ in type = types.nullOr (types.strMatching hostnameRegEx); default = cfg.hostName; example = "Johns-MacBook-Pro"; - description = lib.mdDoc '' + description = '' The local hostname, or local network name, is displayed beneath the computer's name at the top of the Sharing preferences pane. It identifies your Mac to Bonjour-compatible services. @@ -74,7 +74,7 @@ in type = types.listOf types.str; default = []; example = [ "Wi-Fi" "Ethernet Adaptor" "Thunderbolt Ethernet" ]; - description = lib.mdDoc '' + description = '' List of networkservices that should be configured. To display a list of all the network services on the server's @@ -86,13 +86,13 @@ in type = types.listOf types.str; default = []; example = [ "8.8.8.8" "8.8.4.4" "2001:4860:4860::8888" "2001:4860:4860::8844" ]; - description = lib.mdDoc "The list of dns servers used when resolving domain names."; + description = "The list of dns servers used when resolving domain names."; }; networking.search = mkOption { type = types.listOf types.str; default = []; - description = lib.mdDoc "The list of search paths used when resolving domain names."; + description = "The list of search paths used when resolving domain names."; }; }; -- cgit v1.2.3 From 7a3ec6459c4394767ebcc136c0da0bb0c73d76ed Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 22 Oct 2024 09:34:25 +1100 Subject: networking: use `lib.escapeShellArgs` instead of custom version --- modules/networking/default.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'modules/networking') diff --git a/modules/networking/default.nix b/modules/networking/default.nix index 1065c26..099c705 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, ... }: with lib; @@ -8,15 +8,14 @@ let hostnameRegEx = ''^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$''; emptyList = lst: if lst != [] then lst else ["empty"]; - quoteStrings = concatMapStringsSep " " (str: "'${str}'"); setNetworkServices = optionalString (cfg.knownNetworkServices != []) '' networkservices=$(networksetup -listallnetworkservices) ${concatMapStringsSep "\n" (srv: '' case "$networkservices" in - *'${srv}'*) - networksetup -setdnsservers '${srv}' ${quoteStrings (emptyList cfg.dns)} - networksetup -setsearchdomains '${srv}' ${quoteStrings (emptyList cfg.search)} + *${lib.escapeShellArg srv}*) + networksetup -setdnsservers ${lib.escapeShellArgs ([ srv ] ++ (emptyList cfg.dns))} + networksetup -setsearchdomains ${lib.escapeShellArgs ([ srv ] ++ (emptyList cfg.search))} ;; esac '') cfg.knownNetworkServices} -- cgit v1.2.3 From 5907cbbb31d9de387349efb825864a9ee598e6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20B=C3=B8rgesen?= Date: Sat, 18 Nov 2023 14:18:06 +0100 Subject: networking: Add wakeOnLan option --- modules/networking/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules/networking') diff --git a/modules/networking/default.nix b/modules/networking/default.nix index 099c705..b53a9e4 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -9,6 +9,8 @@ let emptyList = lst: if lst != [] then lst else ["empty"]; + onOff = cond: if cond then "on" else "off"; + setNetworkServices = optionalString (cfg.knownNetworkServices != []) '' networkservices=$(networksetup -listallnetworkservices) ${concatMapStringsSep "\n" (srv: '' @@ -93,6 +95,16 @@ in default = []; 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 = { @@ -116,6 +128,10 @@ in ''} ${setNetworkServices} + + ${optionalString (cfg.wakeOnLan.enable != null) '' + systemsetup -setWakeOnNetworkAccess '${onOff cfg.wakeOnLan.enable}' &> /dev/null + ''} ''; }; -- cgit v1.2.3 From 041996803af5497fb000e3f79621fa5bb6995057 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 29 Oct 2024 00:09:37 +1100 Subject: treewide: fix shellcheck warnings and errors --- modules/networking/default.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/networking') diff --git a/modules/networking/default.nix b/modules/networking/default.nix index b53a9e4..7a81ca1 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -118,6 +118,7 @@ in echo "configuring networking..." >&2 ${optionalString (cfg.computerName != null) '' + # shellcheck disable=SC1112 scutil --set ComputerName ${escapeShellArg cfg.computerName} ''} ${optionalString (cfg.hostName != null) '' -- cgit v1.2.3