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:
parent
016b1608ee
commit
62d8f5f289
2 changed files with 12 additions and 4 deletions
|
@ -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) ''
|
||||
|
|
|
@ -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 "[1;31merror: Your system do not support the restartAfterPowerFailure feature[0m" >&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 = ''
|
||||
|
|
Loading…
Add table
Reference in a new issue