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

power: move the check for restartPowerfailure support to checks.nix

This commit is contained in:
gnammix 2024-12-29 12:13:54 +01:00
parent 016b1608ee
commit 62d8f5f289
2 changed files with 12 additions and 4 deletions

View file

@ -35,10 +35,8 @@ in
echo "configuring power..." >&2
${lib.optionalString (cfg.restartAfterPowerFailure != null) ''
if ! systemsetup -getRestartPowerFailure | grep -q "Not supported"; then
systemsetup -setRestartPowerFailure \
'${onOff cfg.restartAfterPowerFailure}' &> /dev/null
fi
systemsetup -setRestartPowerFailure \
'${onOff cfg.restartAfterPowerFailure}' &> /dev/null
''}
${lib.optionalString (cfg.restartAfterFreeze != null) ''

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
echo "error: Your system do not support the restartAfterPowerFailure feature" >&2
echo "Please ensure that power.restartAfterPowerFailure is not set." >&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 = ''