-
-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Power related options (sleep, wake-on-lan, restart after power failure, ...) #813
Conversation
modules/networking/default.nix
Outdated
@@ -94,6 +95,16 @@ in | |||
default = []; | |||
description = lib.mdDoc "The list of search paths used when resolving domain names."; | |||
}; | |||
|
|||
networking.wakeOnLan = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name of option and placement inspired by the NixOS option: networking.interfaces.<name>.wakeOnLan.enable
modules/networking/default.nix
Outdated
@@ -117,6 +128,10 @@ in | |||
''} | |||
|
|||
${setNetworkServices} | |||
|
|||
${optionalString (cfg.wakeOnLan != null) '' | |||
systemsetup -setWakeOnNetworkAccess '${onOff cfg.wakeOnLan}' &> /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemsetup
stdout and stderr are silenced:
- The changed value is echoed on stdout, e.g.
setwakeonnetworkaccess: On
. - An error is reported on stderr, but the command succeeds as reflected by the corresponding get command and System Settings. Example error:
2023-11-18 15:47:54.640 systemsetup[4589:139580] ### Error:-99 File:/AppleInternal/Library/BuildRoots/11aa8fb2-5f4b-11ee-bc7f-926038f30c31/Library/Caches/com.apple.xbs/Sources/Admin/InternetServices.m Line:379
The above observations apply to the new power
and power.sleep
options as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the silencing matches the work done here: #781
4b1fd12
to
7a24217
Compare
@Enzime I hope you don't mind if I ping you on this to get your thoughts. Not my PR but configuring power management would be nice for me now that I am considering retiring my old Mac to be headless. |
Any progress on this? |
2604d65
to
4c40a38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add some tests?
4c40a38
to
4be0c9e
Compare
4be0c9e
to
f737259
Compare
Tests added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the contribution
Hey there, I've recently picked up nix-darwin to configure a Mac Mini M2 as a home server.
I need to configure some power related options that nix-darwin currently does not offer, so I would like to contribute them.
This pull request adds:
networking.wakeOnLan.enable
power.restartAfterPowerFailure
power.restartAfterFreeze
power.sleep.computer
power.sleep.display
power.sleep.harddisk
power.sleep.allowSleepByPowerButton
The options are implemented by means of the
systemsetup
command that also is used for thetime.timezone
option.I believe this is the command that System Settings uses behind the screen.
I've tried to guess where it made most sense to add the new options.
I've added a new
power
module; maybe it would make more sense to place the restartXXX and sleep options undersystem
instead. I'm prepared to move them elsewhere as per your feedback.Thanks for creating nix-darwin!