diff --git a/modules/config/power-management.nix b/modules/config/power-management.nix index a094caae0e0..dd241e4e815 100644 --- a/modules/config/power-management.nix +++ b/modules/config/power-management.nix @@ -11,7 +11,8 @@ let #! ${pkgs.stdenv.shell} action="$1" if [ "$action" = "resume" ]; then - ${cfg.resumeCommands} + ${cfg.resumeCommands} + ${cfg.powerUpCommands} fi ''; @@ -39,6 +40,17 @@ in description = "Commands executed after the system resumes from suspend-to-RAM."; }; + powerUpCommands = mkOption { + default = ""; + example = "${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda"; + description = + '' + Commands executed when the machine powers up. That is, + they're executed both when the system first boots and when + it resumes from suspend or hibernation. + ''; + }; + }; }; diff --git a/modules/system/boot/stage-2.nix b/modules/system/boot/stage-2.nix index b19dbc39183..5c3c3560be3 100644 --- a/modules/system/boot/stage-2.nix +++ b/modules/system/boot/stage-2.nix @@ -29,7 +29,11 @@ let utillinux udev ]; - postBootCommands = writeText "local-cmds" config.boot.postBootCommands; + postBootCommands = writeText "local-cmds" + '' + ${config.boot.postBootCommands} + ${config.powerManagement.powerUpCommands} + ''; }; in