From 9174b4ab421029927fef7febc0645480c10748fa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 15 Nov 2009 12:56:40 +0000 Subject: [PATCH] * Provide a convience option for commands that must be executed both when the system boots and when it resumes from suspend. svn path=/nixos/branches/upstart-0.6/; revision=18354 --- modules/config/power-management.nix | 14 +++++++++++++- modules/system/boot/stage-2.nix | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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