nixpkgs/modules/system/upstart-events/runlevel.nix
Eelco Dolstra ad93acc295 * Make all Upstart jobs shut down on the `starting shutdown' event.
This ensures that they're gone by the time the shutdown job runs, so
  it doesn't have to stop them itself.
* Don't respawn tasks, as it doesn't seem useful (if they fail they're
  likely to fail again if they're restarted).

svn path=/nixos/trunk/; revision=22099
2010-06-02 16:04:08 +00:00

26 lines
497 B
Nix

{ config, pkgs, ... }:
with pkgs.lib;
{
jobs.runlevel =
{ name = "runlevel";
startOn = "runlevel [0123456S]";
task = true;
script =
''
case "$RUNLEVEL" in
0) initctl start shutdown --no-wait MODE=poweroff;;
1) initctl start shutdown --no-wait MODE=maintenance;;
6) initctl start shutdown --no-wait MODE=reboot;;
*) echo "Unsupported runlevel: $RUNLEVEL";;
esac
'';
};
}