* Nixify the Upstart jobs.

svn path=/nixu/trunk/; revision=7075
This commit is contained in:
Eelco Dolstra 2006-11-19 20:07:45 +00:00
parent d191615e96
commit fb4ab4bc8e
9 changed files with 78 additions and 21 deletions

View file

@ -77,12 +77,39 @@ rec {
}; };
# The services (Upstart) configuration for the system.
upstartJobs = import ./upstart-jobs/gather.nix {
inherit (pkgs) stdenv;
jobs = [
# For the builtin logd job.
pkgs.upstart
# The terminals on ttyX.
(map
(ttyNumber: import ./upstart-jobs/mingetty.nix {
inherit (pkgs) genericSubstituter;
mingetty = pkgs.mingettyWrapper;
inherit ttyNumber;
})
[1 2 3 4 5 6]
)
# Syslogd.
(import ./upstart-jobs/syslogd.nix {
inherit (pkgs) genericSubstituter sysklogd;
})
];
};
# The init script of boot stage 2, which is supposed to do # The init script of boot stage 2, which is supposed to do
# everything else to bring up the system. # everything else to bring up the system.
bootStage2 = import ./boot-stage-2.nix { bootStage2 = import ./boot-stage-2.nix {
inherit (pkgs) genericSubstituter coreutils findutils inherit (pkgs) genericSubstituter coreutils findutils
utillinux kernel sysklogd udev module_init_tools utillinux kernel udev module_init_tools
nettools upstart; nettools upstart;
inherit upstartJobs;
shell = pkgs.bash + "/bin/sh"; shell = pkgs.bash + "/bin/sh";
dhcp = pkgs.dhcpWrapper; dhcp = pkgs.dhcpWrapper;
@ -114,8 +141,6 @@ rec {
nixosInstaller nixosInstaller
]; ];
mingetty = pkgs.mingettyWrapper;
inherit readOnlyRoot; inherit readOnlyRoot;
}; };

View file

@ -68,13 +68,10 @@ udevtrigger
udevsettle # wait for udev to finish udevsettle # wait for udev to finish
# Start syslogd. # Necessary configuration for syslogd.
mkdir -m 0755 -p /var/run mkdir -m 0755 -p /var/run
#mkdir -p /var/log
#touch /var/log/messages
echo "*.* /dev/tty10" > /etc/syslog.conf echo "*.* /dev/tty10" > /etc/syslog.conf
echo "syslog 514/udp" > /etc/services # required, even if we don't use it echo "syslog 514/udp" > /etc/services # required, even if we don't use it
@sysklogd@/sbin/syslogd &
# Try to load modules for all PCI devices. # Try to load modules for all PCI devices.
@ -113,17 +110,8 @@ fi
# Set up the Upstart jobs. # Set up the Upstart jobs.
export UPSTART_CFG_DIR=/etc/event.d export UPSTART_CFG_DIR=/etc/event.d
mkdir -p $UPSTART_CFG_DIR
cp -f @upstart@/etc/event.d/logd $UPSTART_CFG_DIR/logd ln -sf @upstartJobs@/etc/event.d /etc/event.d
for i in $(seq 1 6); do
cat > $UPSTART_CFG_DIR/tty$i <<EOF
start on startup
stop on shutdown
respawn @mingetty@/sbin/mingetty --noclear tty$i
EOF
done
# Show a nice greeting on each terminal. # Show a nice greeting on each terminal.
@ -156,7 +144,7 @@ hostname nixos
# Start an interactive shell. # Start an interactive shell.
@shell@ & #exec @shell@
# Start Upstart's init. # Start Upstart's init.

View file

@ -1,17 +1,20 @@
{ genericSubstituter, shell, coreutils, findutils { genericSubstituter, shell, coreutils, findutils
, utillinux, kernel, sysklogd, mingetty, udev , utillinux, kernel, udev
, module_init_tools, nettools, dhcp, upstart , module_init_tools, nettools, dhcp, upstart
, path ? [] , path ? []
, # Whether the root device is root only. If so, we'll mount a , # Whether the root device is root only. If so, we'll mount a
# ramdisk on /etc, /var and so on. # ramdisk on /etc, /var and so on.
readOnlyRoot readOnlyRoot
, # The Upstart job configuration.
upstartJobs
}: }:
genericSubstituter { genericSubstituter {
src = ./boot-stage-2-init.sh; src = ./boot-stage-2-init.sh;
isExecutable = true; isExecutable = true;
inherit shell kernel sysklogd mingetty upstart readOnlyRoot; inherit shell kernel upstart readOnlyRoot upstartJobs;
path = [ path = [
coreutils coreutils
findutils findutils

View file

@ -16,7 +16,7 @@ in
rec { rec {
inherit nixosInstaller bootStage1; # !!! debug inherit nixosInstaller bootStage1 upstartJobs; # !!! debug
# Since the CD is read-only, the mount points must be on disk. # Since the CD is read-only, the mount points must be on disk.

View file

@ -0,0 +1,19 @@
# Create an etc/event.d directory containing symlinks to the
# specified list of Upstart job files.
{stdenv, jobs}:
stdenv.mkDerivation {
name = "upstart-jobs";
inherit jobs;
builder = builtins.toFile "builder.sh" "
source $stdenv/setup
ensureDir $out/etc/event.d
for i in $jobs; do
if test -d $i; then
ln -s $i/etc/event.d/* $out/etc/event.d/
fi
done
";
}

View file

@ -0,0 +1,8 @@
{genericSubstituter, mingetty, ttyNumber}:
genericSubstituter {
src = ./mingetty.sh;
dir = "etc/event.d";
name = "tty" + toString ttyNumber;
inherit mingetty ttyNumber;
}

View file

@ -0,0 +1,3 @@
start on startup
stop on shutdown
respawn @mingetty@/sbin/mingetty --noclear tty@ttyNumber@

View file

@ -0,0 +1,8 @@
{genericSubstituter, sysklogd}:
genericSubstituter {
src = ./syslogd.sh;
dir = "etc/event.d";
name = "syslogd";
inherit sysklogd;
}

View file

@ -0,0 +1,3 @@
start on startup
stop on shutdown
respawn @sysklogd@/sbin/syslogd -n