1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-05 16:27:03 +00:00

Merge pull request #1241 from gnammix/power_conditional_setRestartPowerFailure

power: restartAfterPowerFailure option is carried out conditionally
This commit is contained in:
Michael Hoang 2025-01-04 13:03:10 +11:00 committed by GitHub
commit 3feaf376d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -15,6 +15,8 @@ in
default = null;
description = ''
Whether to restart the computer after a power failure.
Option is not supported on all devices.
'';
};

View file

@ -308,6 +308,15 @@ let
exit 2
fi
'';
# some mac devices, notably notebook do not support restartAfterPowerFailure option
restartAfterPowerFailureIsSupported = ''
if sudo /usr/sbin/systemsetup -getRestartPowerFailure | grep -q "Not supported"; then
printf >&2 "<EFBFBD>[1;31merror: restarting after power failure is not supported on your machine<EFBFBD>[0m\n" >&2
printf >&2 "Please ensure that `power.restartAfterPowerFailure` is not set.\n" >&2
exit 2
fi
'';
in
{
@ -357,6 +366,7 @@ in
(mkIf cfg.verifyNixPath nixPath)
oldSshAuthorizedKeysDirectory
(mkIf config.homebrew.enable homebrewInstalled)
(mkIf (config.power.restartAfterPowerFailure != null) restartAfterPowerFailureIsSupported)
];
system.activationScripts.checks.text = ''