diff options
| author | gnammix <71704832+gnammix@users.noreply.github.com> | 2024-12-29 12:13:54 +0100 |
|---|---|---|
| committer | gnammix <71704832+gnammix@users.noreply.github.com> | 2024-12-29 12:13:54 +0100 |
| commit | 62d8f5f289341497ea0fa21814e734cbea69a0a1 (patch) | |
| tree | 9bb27deb391f5dccb78388e9959979f0d6cf1371 /modules | |
| parent | 016b1608eec6c54cfaece96b63ec9d1a6cd4672b (diff) | |
power: move the check for restartPowerfailure support to checks.nix
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/power/default.nix | 6 | ||||
| -rw-r--r-- | modules/system/checks.nix | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/modules/power/default.nix b/modules/power/default.nix index e36a027..c3e4974 100644 --- a/modules/power/default.nix +++ b/modules/power/default.nix @@ -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) '' diff --git a/modules/system/checks.nix b/modules/system/checks.nix index 796e7e4..e6ee1b3 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -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 = '' |
