From 043276639931093ff45dad23d27180df65158ebd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 26 Jan 2010 21:45:13 +0000 Subject: [PATCH] * Fall back to the kernel modules used at boot time if the modules in the current configuration don't match the running kernel. This ensures that modprobe still works after a "nixos-rebuild switch" to a configuration that has a different kernel version. svn path=/nixos/trunk/; revision=19696 --- modules/system/activation/top-level.nix | 1 + modules/system/boot/modprobe.nix | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index 2fdaa6fd945..0128ffb0c26 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -69,6 +69,7 @@ let false fi ln -s ${kernelPath} $out/kernel + ln -s ${config.system.modulesTree} $out/kernel-modules if [ -n "$grub" ]; then ln -s $grub $out/grub fi diff --git a/modules/system/boot/modprobe.nix b/modules/system/boot/modprobe.nix index 4496106a231..65b3f6fd292 100644 --- a/modules/system/boot/modprobe.nix +++ b/modules/system/boot/modprobe.nix @@ -19,6 +19,14 @@ with pkgs.lib; '' #! ${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 "$@" ''; };