diff --git a/upstart-jobs/alsa.nix b/upstart-jobs/alsa.nix index 319918117daa..df6f632973c9 100644 --- a/upstart-jobs/alsa.nix +++ b/upstart-jobs/alsa.nix @@ -19,33 +19,32 @@ in } ]; - job = " -start on hardware-scan -stop on shutdown + job = '' + start on udev + stop on shutdown -start script + start script - mkdir -m 0755 -p $(dirname ${soundState}) + mkdir -m 0755 -p $(dirname ${soundState}) - # Load some additional modules. - for mod in snd_pcm_oss; do - ${modprobe}/sbin/modprobe $mod || true - done + # Load some additional modules. + for mod in snd_pcm_oss; do + ${modprobe}/sbin/modprobe $mod || true + done - # Restore the sound state. - ${alsaUtils}/sbin/alsactl -f ${soundState} restore + # Restore the sound state. + ${alsaUtils}/sbin/alsactl -f ${soundState} restore -end script + end script -respawn sleep 1000000 # !!! hack + respawn sleep 1000000 # !!! hack -stop script + stop script - # Save the sound state. - ${alsaUtils}/sbin/alsactl -f ${soundState} store + # Save the sound state. + ${alsaUtils}/sbin/alsactl -f ${soundState} store -end script - - "; + end script + ''; } diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index e603f5ec953c..a3e988eab767 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -88,6 +88,7 @@ let # The udev daemon creates devices nodes and runs programs when # hardware events occur. (import ../upstart-jobs/udev.nix { + inherit modprobe; inherit (pkgs) stdenv writeText substituteAll udev procps; inherit (pkgs.lib) cleanSource; firmwareDirs = @@ -115,13 +116,6 @@ let inherit (pkgs) mdadm; }) - # Hardware scan; loads modules for PCI devices. - (import ../upstart-jobs/hardware-scan.nix { - inherit modprobe; - doHardwareScan = config.boot.hardwareScan; - kernelModules = config.boot.kernelModules; - }) - # Mount file systems. (import ../upstart-jobs/filesystems.nix { inherit (pkgs) utillinux e2fsprogs; diff --git a/upstart-jobs/hardware-scan.nix b/upstart-jobs/hardware-scan.nix deleted file mode 100644 index f5f45b0787b9..000000000000 --- a/upstart-jobs/hardware-scan.nix +++ /dev/null @@ -1,28 +0,0 @@ -{modprobe, doHardwareScan, kernelModules}: - -{ - name = "hardware-scan"; - - job = '' - start on udev - - script - for i in ${toString kernelModules}; do - echo "Loading kernel module $i..." - ${modprobe}/sbin/modprobe $i || true - done - - if test -n "${toString doHardwareScan}" -a ! -e /var/run/safemode; then - - # Try to load modules for all PCI and USB devices. - for i in /sys/bus/pci/devices/*/modalias /sys/bus/usb/devices/*/modalias; do - echo "Trying to load a module for $(basename $(dirname $i))..." - ${modprobe}/sbin/modprobe $(cat $i) || true - echo "" - done - - fi - end script - ''; - -} diff --git a/upstart-jobs/network-interfaces.nix b/upstart-jobs/network-interfaces.nix index 610ff550536f..61469fffbd6d 100644 --- a/upstart-jobs/network-interfaces.nix +++ b/upstart-jobs/network-interfaces.nix @@ -16,86 +16,85 @@ in { name = "network-interfaces"; - job = " -start on hardware-scan -stop on shutdown + job = '' + start on udev + stop on shutdown -start script - export PATH=${modprobe}/sbin:$PATH - modprobe af_packet || true + start script + export PATH=${modprobe}/sbin:$PATH + modprobe af_packet || true - for i in $(cd /sys/class/net && ls -d *); do - echo \"Bringing up network device $i...\" - ${nettools}/sbin/ifconfig $i up || true - done - - # Configure the manually specified interfaces. - names=(${toString names}) - ipAddresses=(${toString ipAddresses}) - subnetMasks=(${toString subnetMasks}) - essids=(${toString essids}) - wepKeys=(${toString wepKeys}) - - for ((n = 0; n < \${#names[*]}; n++)); do - name=\${names[$n]} - ipAddress=\${ipAddresses[$n]} - subnetMask=\${subnetMasks[$n]} - essid=\${essids[$n]} - wepKey=\${wepKeys[$n]} - - # Set wireless networking stuff. - if test \"$essid\" != default; then - ${wirelesstools}/sbin/iwconfig \"$name\" essid \"$essid\" || true - fi - - if test \"$wepKey\" != nokey; then - ${wirelesstools}/sbin/iwconfig \"$name\" key \"$(cat \"$wepKey\")\" || true - fi - - # Set IP address / netmask. - if test \"$ipAddress\" != dhcp; then - echo \"Configuring interface $name...\" - extraFlags= - if test \"$subnetMask\" != default; then - extraFlags=\"$extraFlags netmask $subnetMask\" - fi - ${nettools}/sbin/ifconfig \"$name\" \"$ipAddress\" $extraFlags || true - fi - - done - - # Set the nameservers. - if test -n \"${toString cfg.nameservers}\"; then - rm -f /etc/resolv.conf - if test -n \"${cfg.domain}\"; then - echo \"domain ${cfg.domain}\" >> /etc/resolv.conf - fi - for i in ${toString cfg.nameservers}; do - echo \"nameserver $i\" >> /etc/resolv.conf + for i in $(cd /sys/class/net && ls -d *); do + echo "Bringing up network device $i..." + ${nettools}/sbin/ifconfig $i up || true done - fi - # Set the default gateway. - if test -n \"${cfg.defaultGateway}\"; then - ${nettools}/sbin/route add default gw \"${cfg.defaultGateway}\" || true - fi + # Configure the manually specified interfaces. + names=(${toString names}) + ipAddresses=(${toString ipAddresses}) + subnetMasks=(${toString subnetMasks}) + essids=(${toString essids}) + wepKeys=(${toString wepKeys}) - # Run any user-specified commands. - ${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true + for ((n = 0; n < ''${#names[*]}; n++)); do + name=''${names[$n]} + ipAddress=''${ipAddresses[$n]} + subnetMask=''${subnetMasks[$n]} + essid=''${essids[$n]} + wepKey=''${wepKeys[$n]} -end script + # Set wireless networking stuff. + if test "$essid" != default; then + ${wirelesstools}/sbin/iwconfig "$name" essid "$essid" || true + fi -# Hack: Upstart doesn't yet support what we want: a service that -# doesn't have a running process associated with it. -respawn sleep 100000 + if test "$wepKey" != nokey; then + ${wirelesstools}/sbin/iwconfig "$name" key "$(cat "$wepKey")" || true + fi -stop script - for i in $(cd /sys/class/net && ls -d *); do - echo \"Taking down network device $i...\" - ${nettools}/sbin/ifconfig $i down || true - done -end script + # Set IP address / netmask. + if test "$ipAddress" != dhcp; then + echo "Configuring interface $name..." + extraFlags= + if test "$subnetMask" != default; then + extraFlags="$extraFlags netmask $subnetMask" + fi + ${nettools}/sbin/ifconfig "$name" "$ipAddress" $extraFlags || true + fi - "; + done + + # Set the nameservers. + if test -n "${toString cfg.nameservers}"; then + rm -f /etc/resolv.conf + if test -n "${cfg.domain}"; then + echo "domain ${cfg.domain}" >> /etc/resolv.conf + fi + for i in ${toString cfg.nameservers}; do + echo "nameserver $i" >> /etc/resolv.conf + done + fi + + # Set the default gateway. + if test -n "${cfg.defaultGateway}"; then + ${nettools}/sbin/route add default gw "${cfg.defaultGateway}" || true + fi + + # Run any user-specified commands. + ${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true + + end script + + # Hack: Upstart doesn't yet support what we want: a service that + # doesn't have a running process associated with it. + respawn sleep 100000 + + stop script + for i in $(cd /sys/class/net && ls -d *); do + echo "Taking down network device $i..." + ${nettools}/sbin/ifconfig $i down || true + done + end script + ''; } diff --git a/upstart-jobs/tty-backgrounds.nix b/upstart-jobs/tty-backgrounds.nix index d83291d7a05f..a567e21ed319 100644 --- a/upstart-jobs/tty-backgrounds.nix +++ b/upstart-jobs/tty-backgrounds.nix @@ -22,7 +22,7 @@ rec { ]; job = '' - start on hardware-scan + start on udev start script diff --git a/upstart-jobs/udev.nix b/upstart-jobs/udev.nix index 9c8e6f9b3fb4..5d8e8269cea9 100644 --- a/upstart-jobs/udev.nix +++ b/upstart-jobs/udev.nix @@ -1,4 +1,4 @@ -{ stdenv, writeText, substituteAll, cleanSource, udev, procps, firmwareDirs +{ stdenv, writeText, substituteAll, cleanSource, udev, procps, firmwareDirs, modprobe , extraUdevPkgs ? [] , sndMode ? "0600" }: @@ -44,9 +44,9 @@ let ensureDir $out ln -s ${nixRules} $out/${nixRules.name} shopt -s nullglob - cp ${udev}/etc/udev/rules.d/50-udev-default.rules $out/ - cp ${udev}/etc/udev/rules.d/60-persistent-storage.rules $out/ - cp ${udev}/etc/udev/rules.d/95-udev-late.rules $out/ + cp ${udev}/etc/udev/rules.d/*.rules $out/ + substituteInPlace $out/80-drivers.rules \ + --replace /sbin/modprobe ${modprobe}/sbin/modprobe for i in ${toString extraUdevPkgs}; do for j in $i/etc/udev/rules.d/*; do ln -s $j $out/$(basename $j)