diff --git a/modules/services/ttys/mingetty.nix b/modules/services/ttys/mingetty.nix index 6c793ffa112..5f6b1d0f14c 100644 --- a/modules/services/ttys/mingetty.nix +++ b/modules/services/ttys/mingetty.nix @@ -55,7 +55,7 @@ with pkgs.lib; # Generate a separate job for each tty. jobs = listToAttrs (map (tty: nameValuePair tty { - startOn = "udev"; + startOn = "started udev"; exec = "${pkgs.mingetty}/sbin/mingetty --loginprog=${pkgs.pam_login}/bin/login --noclear ${tty}"; diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index 0cc09caebba..a95ff1873ef 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -106,9 +106,11 @@ if test -n "$safeMode"; then fi -# Create the minimal device nodes needed before we run udev. +# Create the minimal device nodes needed for the activation scripts +# and Upstart. mknod -m 0666 /dev/null c 1 3 mknod -m 0644 /dev/urandom c 1 9 # needed for passwd +mknod -m 0644 /dev/console c 5 1 # Clear the resume device. @@ -136,12 +138,12 @@ export MODULE_DIR=@kernel@/lib/modules/ # Run any user-specified commands. @shell@ @postBootCommands@ -echo "starting Upstart..." +# For debugging Upstart. +#@shell@ --login < /dev/console > /dev/console 2>&1 & # Start Upstart's init. We start it through the # /var/run/current-system symlink indirection so that we can upgrade # init in a running system by changing the symlink and sending init a # HUP signal. -export UPSTART_CFG_DIR=/etc/event.d -setPath "@upstartPath@" -exec /var/run/current-system/upstart/sbin/init +echo "starting Upstart..." +exec /var/run/current-system/upstart/sbin/init -v diff --git a/modules/system/boot/stage-2.nix b/modules/system/boot/stage-2.nix index 41c53c492f4..b19dbc39183 100644 --- a/modules/system/boot/stage-2.nix +++ b/modules/system/boot/stage-2.nix @@ -18,26 +18,16 @@ let inherit (pkgs) substituteAll writeText coreutils utillinux udev; kernel = config.boot.kernelPackages.kernel; activateConfiguration = config.system.activationScripts.script; - upstart = config.system.build.upstart; - - # Path for Upstart jobs. Should be quite minimal. - upstartPath = - [ pkgs.coreutils - pkgs.findutils - pkgs.gnugrep - pkgs.gnused - upstart - ]; bootStage2 = substituteAll { src = ./stage-2-init.sh; isExecutable = true; - inherit kernel upstart activateConfiguration upstartPath; + inherit kernel activateConfiguration; + upstart = config.system.build.upstart; path = [ coreutils utillinux udev - upstart ]; postBootCommands = writeText "local-cmds" config.boot.postBootCommands; }; diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index a0f5b5802da..0919fc0d75f 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -4,9 +4,19 @@ with pkgs.lib; let - upstart = pkgs.upstart; + upstart = pkgs.upstart06; + # Path for Upstart jobs. Should be quite minimal. + upstartPath = + [ pkgs.coreutils + pkgs.findutils + pkgs.gnugrep + pkgs.gnused + upstart + ]; + + # From a job description, generate an Upstart job file. makeJob = job: @@ -18,6 +28,8 @@ let description "${job.description}" + console output + ${if isList job.startOn then # This is a hack to support or-dependencies on Upstart 0.3. concatMapStrings (x: "start on ${x}\n") job.startOn @@ -28,10 +40,11 @@ let ${if job.stopOn != "" then "stop on ${job.stopOn}" else ""} + env PATH=${makeSearchPath "bin" upstartPath}:${makeSearchPath "sbin" upstartPath} ${concatMapStrings (n: "env ${n}=${getAttr n job.environment}\n") (attrNames job.environment)} ${if job.preStart != "" then '' - start script + pre-start script ${job.preStart} end script '' else ""} @@ -48,18 +61,13 @@ let '' exec ${job.exec} '' - else - # Simulate jobs without a main process (which Upstart 0.3 - # doesn't support) using a semi-infinite sleep. - '' - exec sleep 1e100 - '' + else "" } ${if job.respawn && !job.task then "respawn" else ""} ${if job.postStop != "" then '' - stop script + post-stop script ${job.postStop} end script '' else ""} @@ -68,37 +76,14 @@ let ''; in - pkgs.runCommand ("upstart-" + job.name) + pkgs.runCommand ("upstart-" + job.name + ".conf") { inherit (job) buildHook; inherit jobText; } '' eval "$buildHook" - ensureDir $out/etc/event.d - echo "$jobText" > $out/etc/event.d/${job.name} + echo "$jobText" > $out ''; - jobs = - [ upstart ] # for the built-in logd job - ++ map (job: job.upstartPkg) (attrValues config.jobs); - - - # Create an etc/event.d directory containing symlinks to the - # specified list of Upstart job files. - jobsDir = pkgs.runCommand "upstart-jobs" {inherit jobs;} - '' - ensureDir $out/etc/event.d - for i in $jobs; do - if ln -s $i . ; then - if test -d $i; then - ln -s $i/etc/event.d/* $out/etc/event.d/ - fi - else - echo Duplicate entry: $i; - fi; - done - ''; # */ - - jobOptions = { name = mkOption { @@ -227,13 +212,12 @@ let upstartJob = {name, config, ...}: { options = { - upstartPkg = mkOption { + jobDrv = mkOption { default = makeJob config; type = types.uniq types.package; description = '' - Upstart package which contains upstart events inside - /etc/event.d/. The default value is - generated from other options. + Derivation that builds the Upstart job file. The default + value is generated from other options. ''; }; }; @@ -284,18 +268,19 @@ in system.build.upstart = upstart; environment.etc = - [ { # The Upstart events defined above. - source = "${jobsDir}/etc/event.d"; - target = "event.d"; - } - ]; + flip map (attrValues config.jobs) (job: + { source = job.jobDrv; + target = "init/${job.name}.conf"; + } ); # !!! fix this + /* tests.upstartJobs = { recurseForDerivations = true; } // builtins.listToAttrs (map (job: { name = removePrefix "upstart-" job.name; value = job; }) jobs); + */ }; diff --git a/modules/tasks/tty-backgrounds.nix b/modules/tasks/tty-backgrounds.nix index d15365fab9d..5f557ac7f5c 100644 --- a/modules/tasks/tty-backgrounds.nix +++ b/modules/tasks/tty-backgrounds.nix @@ -105,7 +105,7 @@ in jobs.ttyBackgrounds = { name = "tty-backgrounds"; - startOn = "udev"; + startOn = "started udev"; preStart = ''