mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 15:11:35 +00:00
* Use Upstart 0.6. Jobs are now in /etc/init instead of /etc/event.d.
svn path=/nixos/branches/upstart-0.6/; revision=18192
This commit is contained in:
parent
b581a56d79
commit
7011a9315f
|
@ -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}";
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
<filename>/etc/event.d/</filename>. 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);
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ in
|
|||
jobs.ttyBackgrounds =
|
||||
{ name = "tty-backgrounds";
|
||||
|
||||
startOn = "udev";
|
||||
startOn = "started udev";
|
||||
|
||||
preStart =
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue