Author: urkud
Date: Mon Mar 26 15:20:29 2012
New Revision: 33430
URL: https://nixos.org/websvn/nix/?rev=33430&sc=1
Log:
Make NixOS work with vanilla modprobe
Create /lib/modules/$version symlink instead of exporting MODULE_DIR
Modified:
nixos/branches/kmod-MODULE_DIR/modules/config/system-path.nix
nixos/branches/kmod-MODULE_DIR/modules/services/hardware/hal.nix
nixos/branches/kmod-MODULE_DIR/modules/services/hardware/udev.nix
nixos/branches/kmod-MODULE_DIR/modules/system/boot/modprobe.nix
nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1-init.sh
nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1.nix
Modified: nixos/branches/kmod-MODULE_DIR/modules/config/system-path.nix
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/config/system-path.nix Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/config/system-path.nix Mon Mar
26 15:20:29 2012 (r33430)
@@ -16,7 +16,7 @@
'';
requiredPackages =
- [ config.system.sbin.modprobe # must take precedence over module_init_tools
+ [
config.system.build.upstart
config.environment.nix
pkgs.acl
Modified: nixos/branches/kmod-MODULE_DIR/modules/services/hardware/hal.nix
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/services/hardware/hal.nix Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/services/hardware/hal.nix Mon Mar
26 15:20:29 2012 (r33430)
@@ -84,7 +84,6 @@
"${pkgs.dbus_tools}/bin"
"${pkgs.procps}/bin"
"${pkgs.procps}/sbin"
- "${config.system.sbin.modprobe}/sbin"
"${pkgs.module_init_tools}/bin"
"${pkgs.module_init_tools}/sbin"
"${pkgs.kbd}/bin"
Modified: nixos/branches/kmod-MODULE_DIR/modules/services/hardware/udev.nix
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/services/hardware/udev.nix Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/services/hardware/udev.nix Mon Mar
26 15:20:29 2012 (r33430)
@@ -47,7 +47,7 @@
# Fix some paths in the standard udev rules. Hacky.
for i in $out/*.rules; do
substituteInPlace $i \
- --replace \"/sbin/modprobe
\"${config.system.sbin.modprobe}/sbin/modprobe \
+ --replace \"/sbin/modprobe \"${pkgs.module_init_tools}/sbin/modprobe
\
--replace \"/sbin/mdadm \"${pkgs.mdadm}/sbin/mdadm \
--replace \"/sbin/blkid \"${pkgs.utillinux}/sbin/blkid \
--replace \"/bin/mount \"${pkgs.utillinux}/bin/mount
@@ -239,7 +239,7 @@
# the modules may call upon udev's firmware loading rule.
for i in ${toString config.boot.kernelModules}; do
echo "loading kernel module ā$iā..."
- ${config.system.sbin.modprobe}/sbin/modprobe $i || true
+ ${pkgs.module_init_tools}/sbin/modprobe $i || true
done
'';
};
Modified: nixos/branches/kmod-MODULE_DIR/modules/system/boot/modprobe.nix
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/system/boot/modprobe.nix Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/system/boot/modprobe.nix Mon Mar
26 15:20:29 2012 (r33430)
@@ -8,34 +8,6 @@
options = {
- system.sbin.modprobe = mkOption {
- # should be moved in module-init-tools
- internal = true;
- default = pkgs.writeTextFile {
- name = "modprobe";
- destination = "/sbin/modprobe";
- executable = true;
- text =
- ''
- #! ${pkgs.stdenv.shell}
- export MODULE_DIR=${config.system.modulesTree}/lib/modules/
-
- # Fall back to the kernel modules used at boot time if the
- # modules in the current configuration don't match the
- # running kernel.
- if [ ! -d "$MODULE_DIR/$(${pkgs.coreutils}/bin/uname -r)" ]; then
- MODULE_DIR=/var/run/booted-system/kernel-modules/lib/modules/
- fi
-
- exec ${pkgs.module_init_tools}/sbin/modprobe "$@"
- '';
- };
- description = ''
- Wrapper around modprobe that sets the path to the modules
- tree.
- '';
- };
-
boot.blacklistedKernelModules = mkOption {
default = [];
example = [ "cirrusfb" "i2c_piix4" ];
@@ -94,19 +66,20 @@
];
system.activationScripts.modprobe =
+ # TODO: cleanup old symlinks
+ let
+ version = config.boot.kernelPackages.kernel.modDirVersion;
+ inherit (config.system) modulesTree;
+ src = "${modulesTree}${dest}";
+ dest = "/lib/modules/${version}";
+ in
''
- # 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.
- echo ${config.system.sbin.modprobe}/sbin/modprobe >
/proc/sys/kernel/modprobe
+ mkdir -p /lib/modules
+ ln -sfn ${src} ${dest}.tmp
+ mv -T -f ${dest}.tmp ${dest}
+ ls -l ${dest}
+ echo ${pkgs.kmod}/sbin/modprobe > /proc/sys/kernel/modprobe
'';
-
- environment.shellInit =
- ''
- export MODULE_DIR=${config.system.modulesTree}/lib/modules/
- '';
-
};
}
Modified: nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1-init.sh
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1-init.sh Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1-init.sh Mon Mar
26 15:20:29 2012 (r33430)
@@ -118,6 +118,8 @@
# Load the required kernel modules.
+mkdir /lib
+ln -s @modulesClosure@/lib/modules /lib/modules
echo @extraUtils@/bin/modprobe > /proc/sys/kernel/modprobe
for i in @kernelModules@; do
echo "loading module $(basename $i)..."
Modified: nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1.nix
==============================================================================
--- nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1.nix Mon Mar
26 15:17:06 2012 (r33429)
+++ nixos/branches/kmod-MODULE_DIR/modules/system/boot/stage-1.nix Mon Mar
26 15:20:29 2012 (r33430)
@@ -107,13 +107,12 @@
kernelPackages = config.boot.kernelPackages;
- modulesTree = config.system.modulesTree;
# Determine the set of modules that we need to mount the root FS.
modulesClosure = pkgs.makeModulesClosure {
rootModules = config.boot.initrd.availableKernelModules ++
config.boot.initrd.kernelModules;
- kernel = modulesTree;
+ inherit (config.system) modulesTree;
allowMissing = true;
};
@@ -179,7 +178,8 @@
ln -sv bash $out/bin/sh
# Copy modprobe.
- cp -v ${pkgs.module_init_tools}/sbin/modprobe $out/bin/modprobe.real
+ cp -v ${pkgs.kmod}/bin/kmod $out/bin/modprobe
+ cp -v ${pkgs.kmod}/lib/libkmod.so.* $out/lib
# Maybe copy splashutils.
${optionalString enableSplashScreen ''
@@ -201,14 +201,6 @@
fi
done
- # Make the modprobe wrapper that sets $MODULE_DIR.
- cat > $out/bin/modprobe <<EOF
- #! $out/bin/bash
- export MODULE_DIR=${modulesClosure}/lib/modules
- exec $out/bin/modprobe.real "\$@"
- EOF
- chmod u+x $out/bin/modprobe
-
# Make sure that the patchelf'ed binaries still work.
echo "testing patched programs..."
$out/bin/bash --version | grep "bash, version"
@@ -295,7 +287,7 @@
isExecutable = true;
- inherit udevConf extraUtils;
+ inherit udevConf extraUtils modulesClosure;
inherit (config.boot) resumeDevice devSize runSize;
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits