From 26e0f711a955f2ce105d4afa76ed18967d56fca4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 12 Jan 2008 23:37:17 +0000 Subject: [PATCH] * Use the aggregator to combine the kernel modules tree with externally-built modules so that (e.g.) "modprobe nvidia" Just Works. svn path=/nixos/trunk/; revision=10129 --- etc/default.nix | 7 ++----- etc/profile.sh | 2 +- system/modprobe | 2 +- system/system.nix | 16 +++++++++++++--- upstart-jobs/xserver.nix | 2 -- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/etc/default.nix b/etc/default.nix index 6bf0b42c9e4..d30c797c44e 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -1,6 +1,5 @@ { config, pkgs, upstartJobs, systemPath, wrapperDir -, defaultShell, extraEtc, nixEnvVars -, kernel ? null +, defaultShell, extraEtc, nixEnvVars, modulesTree }: let @@ -108,13 +107,11 @@ import ../helpers/make-etc.nix { { # Script executed when the shell starts. source = pkgs.substituteAll { src = ./profile.sh; - inherit systemPath wrapperDir; + inherit systemPath wrapperDir modulesTree; inherit (pkgs) glibc; timeZone = config.time.timeZone; defaultLocale = config.i18n.defaultLocale; inherit nixEnvVars; - systemKernel = (if kernel == null then - pkgs.systemKernel else kernel); }; target = "profile"; } diff --git a/etc/profile.sh b/etc/profile.sh index aa164b2de9b..27d265f74ac 100644 --- a/etc/profile.sh +++ b/etc/profile.sh @@ -1,5 +1,5 @@ export PATH=@wrapperDir@:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin -export MODULE_DIR=@systemKernel@/lib/modules +export MODULE_DIR=@modulesTree@/lib/modules export NIXPKGS_CONFIG=/nix/etc/config.nix export PAGER=less export TZ=@timeZone@ diff --git a/system/modprobe b/system/modprobe index 5971880f064..293d9bbfd5f 100644 --- a/system/modprobe +++ b/system/modprobe @@ -1,3 +1,3 @@ #! @shell@ -export MODULE_DIR=@kernel@/lib/modules +export MODULE_DIR=@modulesTree@/lib/modules exec @module_init_tools@/sbin/modprobe "$@" diff --git a/system/system.nix b/system/system.nix index 5b6f23749f0..21e8c06a8be 100644 --- a/system/system.nix +++ b/system/system.nix @@ -142,13 +142,24 @@ rec { (map (mod: mod + "/lib") nssModules)); + # Tree of kernel modules. This includes the kernel, plus modules + # built outside of the kernel. We have to combine these into a + # single tree of symlinks because modprobe only supports one + # directory. + modulesTree = pkgs.module_aggregation ( + [kernel pkgs.iwlwifi] + # !!! this should be declared by the xserver Upstart job. + ++ pkgs.lib.optional (config.services.xserver.enable && config.services.xserver.videoDriver == "nvidia") pkgs.nvidiaDrivers + ); + + # Wrapper around modprobe to set the path to the modules. modprobe = pkgs.substituteAll { dir = "sbin"; src = ./modprobe; isExecutable = true; inherit (pkgs) module_init_tools; - inherit kernel; + inherit modulesTree; }; @@ -171,8 +182,7 @@ rec { # The static parts of /etc. etc = import ../etc/default.nix { inherit config pkgs upstartJobs systemPath wrapperDir - defaultShell nixEnvVars; - inherit kernel; + defaultShell nixEnvVars modulesTree; extraEtc = pkgs.lib.concatLists (map (job: job.extraEtc) upstartJobs.jobs); }; diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index f62f02ece6d..b7ef28943a5 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -363,8 +363,6 @@ rec { ${if videoDriver == "nvidia" then '' ln -sf ${pkgs.nvidiaDrivers} /var/run/opengl-driver - # Ideally, the nvidia driver would be somewhere where modprobe looks for it... - ${pkgs.module_init_tools}/sbin/insmod ${pkgs.nvidiaDrivers}/lib/nvidia.ko || true '' else if cfg.driSupport then "ln -sf ${pkgs.mesa} /var/run/opengl-driver"