forked from mirrors/nixpkgs
* Generate a wrapper around modprobe that sets MODULE_DIR. This is
important for /proc/sys/kernel/modprobe, i.e., modprobing by the kernel. svn path=/nixos/trunk/; revision=8164
This commit is contained in:
parent
90f1dbe548
commit
119df37858
|
@ -36,6 +36,14 @@ mkdir -m 0755 -p $mountPoint/bin
|
||||||
ln -sfn @shell@ $mountPoint/bin/sh
|
ln -sfn @shell@ $mountPoint/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
# Allow the kernel to find our wrapped modprobe (which searches in the
|
||||||
|
# right location in the Nix store for kernel modules). We need this
|
||||||
|
# when the kernel (or some module) auto-loads a module.
|
||||||
|
# !!! maybe this should only happen at boot time, since we shouldn't
|
||||||
|
# use modules that don't match the running kernel.
|
||||||
|
echo @modprobe@/sbin/modprobe > /proc/sys/kernel/modprobe
|
||||||
|
|
||||||
|
|
||||||
# Various log directories.
|
# Various log directories.
|
||||||
mkdir -m 0755 -p /var/run
|
mkdir -m 0755 -p /var/run
|
||||||
|
|
||||||
|
|
3
system/modprobe
Normal file
3
system/modprobe
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! @shell@
|
||||||
|
export MODULE_DIR=@kernel@/lib/modules
|
||||||
|
exec @module_init_tools@/sbin/modprobe "$@"
|
|
@ -131,9 +131,18 @@ rec {
|
||||||
(map (mod: mod + "/lib") nssModules));
|
(map (mod: mod + "/lib") nssModules));
|
||||||
|
|
||||||
|
|
||||||
|
# Wrapper around modprobe to set the path to the modules.
|
||||||
|
modprobe = pkgs.substituteAll {
|
||||||
|
dir = "sbin";
|
||||||
|
src = ./modprobe;
|
||||||
|
isExecutable = true;
|
||||||
|
inherit (pkgs) kernel module_init_tools;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
# The services (Upstart) configuration for the system.
|
# The services (Upstart) configuration for the system.
|
||||||
upstartJobs = import ./upstart.nix {
|
upstartJobs = import ./upstart.nix {
|
||||||
inherit config pkgs nix nssModulesPath;
|
inherit config pkgs nix modprobe nssModulesPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +164,7 @@ rec {
|
||||||
|
|
||||||
# The packages you want in the boot environment.
|
# The packages you want in the boot environment.
|
||||||
systemPathList = [
|
systemPathList = [
|
||||||
|
modprobe # must take precedence over module_init_tools
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
pkgs.bzip2
|
pkgs.bzip2
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
|
@ -220,7 +230,7 @@ rec {
|
||||||
src = ./activate-configuration.sh;
|
src = ./activate-configuration.sh;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
|
|
||||||
inherit etc wrapperDir systemPath;
|
inherit etc wrapperDir systemPath modprobe;
|
||||||
inherit (pkgs) kernel;
|
inherit (pkgs) kernel;
|
||||||
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
|
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
|
||||||
hostName = config.get ["networking" "hostName"];
|
hostName = config.get ["networking" "hostName"];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{config, pkgs, nix, nssModulesPath}:
|
{config, pkgs, nix, modprobe, nssModulesPath}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -31,17 +31,19 @@ import ../upstart-jobs/gather.nix {
|
||||||
|
|
||||||
# Makes LVM logical volumes available.
|
# Makes LVM logical volumes available.
|
||||||
(import ../upstart-jobs/lvm.nix {
|
(import ../upstart-jobs/lvm.nix {
|
||||||
inherit (pkgs) kernel module_init_tools lvm2;
|
inherit modprobe;
|
||||||
|
inherit (pkgs) lvm2;
|
||||||
})
|
})
|
||||||
|
|
||||||
# Activate software RAID arrays.
|
# Activate software RAID arrays.
|
||||||
(import ../upstart-jobs/swraid.nix {
|
(import ../upstart-jobs/swraid.nix {
|
||||||
inherit (pkgs) kernel module_init_tools mdadm;
|
inherit modprobe;
|
||||||
|
inherit (pkgs) mdadm;
|
||||||
})
|
})
|
||||||
|
|
||||||
# Hardware scan; loads modules for PCI devices.
|
# Hardware scan; loads modules for PCI devices.
|
||||||
(import ../upstart-jobs/hardware-scan.nix {
|
(import ../upstart-jobs/hardware-scan.nix {
|
||||||
inherit (pkgs) kernel module_init_tools;
|
inherit modprobe;
|
||||||
doHardwareScan = config.get ["boot" "hardwareScan"];
|
doHardwareScan = config.get ["boot" "hardwareScan"];
|
||||||
kernelModules = config.get ["boot" "kernelModules"];
|
kernelModules = config.get ["boot" "kernelModules"];
|
||||||
})
|
})
|
||||||
|
@ -60,7 +62,8 @@ import ../upstart-jobs/gather.nix {
|
||||||
|
|
||||||
# Network interfaces.
|
# Network interfaces.
|
||||||
(import ../upstart-jobs/network-interfaces.nix {
|
(import ../upstart-jobs/network-interfaces.nix {
|
||||||
inherit (pkgs) nettools kernel module_init_tools wirelesstools;
|
inherit modprobe;
|
||||||
|
inherit (pkgs) nettools wirelesstools;
|
||||||
nameservers = config.get ["networking" "nameservers"];
|
nameservers = config.get ["networking" "nameservers"];
|
||||||
defaultGateway = config.get ["networking" "defaultGateway"];
|
defaultGateway = config.get ["networking" "defaultGateway"];
|
||||||
interfaces = config.get ["networking" "interfaces"];
|
interfaces = config.get ["networking" "interfaces"];
|
||||||
|
@ -113,7 +116,8 @@ import ../upstart-jobs/gather.nix {
|
||||||
# NTP daemon.
|
# NTP daemon.
|
||||||
++ optional ["services" "ntp" "enable"]
|
++ optional ["services" "ntp" "enable"]
|
||||||
(import ../upstart-jobs/ntpd.nix {
|
(import ../upstart-jobs/ntpd.nix {
|
||||||
inherit (pkgs) ntp kernel module_init_tools glibc pwdutils writeText;
|
inherit modprobe;
|
||||||
|
inherit (pkgs) ntp glibc pwdutils writeText;
|
||||||
servers = config.get ["services" "ntp" "servers"];
|
servers = config.get ["services" "ntp" "servers"];
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -136,7 +140,8 @@ import ../upstart-jobs/gather.nix {
|
||||||
# ALSA sound support.
|
# ALSA sound support.
|
||||||
++ optional ["sound" "enable"]
|
++ optional ["sound" "enable"]
|
||||||
(import ../upstart-jobs/alsa.nix {
|
(import ../upstart-jobs/alsa.nix {
|
||||||
inherit (pkgs) kernel module_init_tools alsaUtils;
|
inherit modprobe;
|
||||||
|
inherit (pkgs) alsaUtils;
|
||||||
})
|
})
|
||||||
|
|
||||||
# Handles the reboot/halt events.
|
# Handles the reboot/halt events.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{kernel, module_init_tools, alsaUtils}:
|
{modprobe, alsaUtils}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -16,9 +16,8 @@ stop on shutdown
|
||||||
start script
|
start script
|
||||||
|
|
||||||
# Load some additional modules.
|
# Load some additional modules.
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
|
||||||
for mod in snd_pcm_oss; do
|
for mod in snd_pcm_oss; do
|
||||||
${module_init_tools}/sbin/modprobe $mod || true
|
${modprobe}/sbin/modprobe $mod || true
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restore the sound state.
|
# Restore the sound state.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# !!! Don't like it that I have to pass the kernel here.
|
{modprobe, doHardwareScan, kernelModules}:
|
||||||
{kernel, module_init_tools, doHardwareScan, kernelModules}:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "hardware-scan";
|
name = "hardware-scan";
|
||||||
|
@ -8,11 +7,9 @@
|
||||||
start on udev
|
start on udev
|
||||||
|
|
||||||
script
|
script
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
|
||||||
|
|
||||||
for i in ${toString kernelModules}; do
|
for i in ${toString kernelModules}; do
|
||||||
echo \"Loading kernel module $i...\"
|
echo \"Loading kernel module $i...\"
|
||||||
${module_init_tools}/sbin/modprobe $i || true
|
${modprobe}/sbin/modprobe $i || true
|
||||||
done
|
done
|
||||||
|
|
||||||
if test -n \"${toString doHardwareScan}\" -a ! -e /var/run/safemode; then
|
if test -n \"${toString doHardwareScan}\" -a ! -e /var/run/safemode; then
|
||||||
|
@ -20,7 +17,7 @@ script
|
||||||
# Try to load modules for all PCI devices.
|
# Try to load modules for all PCI devices.
|
||||||
for i in /sys/bus/pci/devices/*/modalias; do
|
for i in /sys/bus/pci/devices/*/modalias; do
|
||||||
echo \"Trying to load a module for $(basename $(dirname $i))...\"
|
echo \"Trying to load a module for $(basename $(dirname $i))...\"
|
||||||
${module_init_tools}/sbin/modprobe $(cat $i) || true
|
${modprobe}/sbin/modprobe $(cat $i) || true
|
||||||
echo \"\"
|
echo \"\"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{kernel, module_init_tools, lvm2}:
|
{modprobe, lvm2}:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "lvm";
|
name = "lvm";
|
||||||
|
@ -10,8 +10,7 @@ start on udev
|
||||||
script
|
script
|
||||||
|
|
||||||
# Load the device mapper.
|
# Load the device mapper.
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
${modprobe}/sbin/modprobe dm_mod || true
|
||||||
${module_init_tools}/sbin/modprobe dm_mod || true
|
|
||||||
|
|
||||||
# Scan for block devices that might contain LVM physical volumes
|
# Scan for block devices that might contain LVM physical volumes
|
||||||
# and volume groups.
|
# and volume groups.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# !!! Don't like it that I have to pass the kernel here.
|
{ nettools, modprobe, wirelesstools
|
||||||
{ nettools, kernel, module_init_tools, wirelesstools
|
|
||||||
, nameservers, defaultGateway, interfaces
|
, nameservers, defaultGateway, interfaces
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -22,9 +21,7 @@ start on hardware-scan
|
||||||
stop on shutdown
|
stop on shutdown
|
||||||
|
|
||||||
start script
|
start script
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
${modprobe}/sbin/modprobe af_packet
|
||||||
|
|
||||||
${module_init_tools}/sbin/modprobe af_packet
|
|
||||||
|
|
||||||
for i in $(cd /sys/class/net && ls -d *); do
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
echo \"Bringing up network device $i...\"
|
echo \"Bringing up network device $i...\"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ntp, kernel, module_init_tools, glibc, pwdutils, writeText, servers}:
|
{ntp, modprobe, glibc, pwdutils, writeText, servers}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -37,8 +37,7 @@ start script
|
||||||
chown ${ntpUser} ${stateDir}
|
chown ${ntpUser} ${stateDir}
|
||||||
|
|
||||||
# Needed to run ntpd as an unprivileged user.
|
# Needed to run ntpd as an unprivileged user.
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
${modprobe}/sbin/modprobe capability
|
||||||
${module_init_tools}/sbin/modprobe capability
|
|
||||||
|
|
||||||
${ntp}/bin/ntpd -q -g ${ntpFlags}
|
${ntp}/bin/ntpd -q -g ${ntpFlags}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{kernel, module_init_tools, mdadm}:
|
{modprobe, mdadm}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ start on udev
|
||||||
script
|
script
|
||||||
|
|
||||||
# Load the necessary RAID personalities.
|
# Load the necessary RAID personalities.
|
||||||
export MODULE_DIR=${kernel}/lib/modules/
|
# !!! hm, doesn't the kernel load these automatically?
|
||||||
for mod in raid0 raid1 raid5; do
|
for mod in raid0 raid1 raid5; do
|
||||||
${module_init_tools}/sbin/modprobe $mod || true
|
${modprobe}/sbin/modprobe $mod || true
|
||||||
done
|
done
|
||||||
|
|
||||||
# Scan /proc/partitions for RAID devices.
|
# Scan /proc/partitions for RAID devices.
|
||||||
|
|
Loading…
Reference in a new issue