diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh index 4a4a5f6f7e25..a3387fbac571 100644 --- a/boot/boot-stage-2-init.sh +++ b/boot/boot-stage-2-init.sh @@ -10,13 +10,18 @@ echo # Set the PATH. -export PATH=/empty -for i in @startPath@; do - PATH=$PATH:$i/bin - if test -e $i/sbin; then - PATH=$PATH:$i/sbin - fi -done +setPath() { + local dirs="$1" + export PATH=/empty + for i in $dirs; do + PATH=$PATH:$i/bin + if test -e $i/sbin; then + PATH=$PATH:$i/sbin + fi + done +} + +setPath "@path@" # Mount special file systems. @@ -98,6 +103,5 @@ udevsettle # wait for udev to finish # Start Upstart's init. export UPSTART_CFG_DIR=/etc/event.d -export PATH=/empty -for i in @upstartPath@; do PATH=$PATH:$i/bin; done +setPath "@upstartPath@" exec @upstart@/sbin/init -v diff --git a/boot/boot-stage-2.nix b/boot/boot-stage-2.nix index f501c12017f1..8772759aaf49 100644 --- a/boot/boot-stage-2.nix +++ b/boot/boot-stage-2.nix @@ -10,20 +10,14 @@ upstartPath }: -let - - startPath = [ +substituteAll { + src = ./boot-stage-2-init.sh; + isExecutable = true; + inherit kernel upstart readOnlyRoot activateConfiguration upstartPath; + path = [ coreutils utillinux udev upstart ]; - -in - -substituteAll { - src = ./boot-stage-2-init.sh; - isExecutable = true; - inherit kernel upstart readOnlyRoot activateConfiguration upstartPath; - inherit startPath; } diff --git a/configuration/boot-environment.nix b/configuration/boot-environment.nix index c9e01d1773f2..5ffe95760267 100644 --- a/configuration/boot-environment.nix +++ b/configuration/boot-environment.nix @@ -163,7 +163,7 @@ rec { # Handles the reboot/halt events. ++ (map (event: makeJob (import ../upstart-jobs/halt.nix { - inherit (pkgs) bash; + inherit (pkgs) bash utillinux; inherit event; })) ["reboot" "halt" "system-halt" "power-off"] @@ -172,7 +172,7 @@ rec { # The terminals on ttyX. ++ (map (ttyNumber: makeJob (import ../upstart-jobs/mingetty.nix { - mingetty = pkgs.mingettyWrapper; + inherit (pkgs) mingetty pam_login; inherit ttyNumber; })) [1 2 3 4 5 6] @@ -326,6 +326,7 @@ rec { pkgs.findutils pkgs.gnugrep pkgs.gnused + pkgs.upstart ]; }; diff --git a/upstart-jobs/halt.nix b/upstart-jobs/halt.nix index 58be12db69c4..6e4e833f6439 100644 --- a/upstart-jobs/halt.nix +++ b/upstart-jobs/halt.nix @@ -1,4 +1,4 @@ -{bash, event}: +{bash, event, utillinux}: assert event == "reboot" || event == "halt" @@ -17,6 +17,8 @@ script echo \"<<< SYSTEM SHUTDOWN >>>\" echo \"\" + export PATH=${utillinux}/bin:$PATH + # Do an initial sync just in case. sync || true diff --git a/upstart-jobs/mingetty.nix b/upstart-jobs/mingetty.nix index cdce937535c2..f67a8ced92c4 100644 --- a/upstart-jobs/mingetty.nix +++ b/upstart-jobs/mingetty.nix @@ -1,10 +1,10 @@ -{mingetty, ttyNumber}: +{mingetty, pam_login, ttyNumber}: { name = "tty" + toString ttyNumber; job = " start on startup stop on shutdown - respawn ${mingetty}/sbin/mingetty --noclear tty${toString ttyNumber} + respawn ${mingetty}/sbin/mingetty --loginprog=${pam_login}/bin/login --noclear tty${toString ttyNumber} "; }