···228 systemd.services."systemd-modules-load" =
229 { wantedBy = [ "multi-user.target" ];
230 restartTriggers = [ kernelModulesConf ];
0231 serviceConfig =
232 { # Ignore failed module loads. Typically some of the
233 # modules in ‘boot.kernelModules’ are "nice to have but
···235 # barf on those.
236 SuccessExitStatus = "0 1";
237 };
0000238 };
239240 lib.kernelConfig = {
···228 systemd.services."systemd-modules-load" =
229 { wantedBy = [ "multi-user.target" ];
230 restartTriggers = [ kernelModulesConf ];
231+ environment.MODULE_DIR = "/run/booted-system/kernel-modules/lib/modules";
232 serviceConfig =
233 { # Ignore failed module loads. Typically some of the
234 # modules in ‘boot.kernelModules’ are "nice to have but
···236 # barf on those.
237 SuccessExitStatus = "0 1";
238 };
239+ };
240+241+ systemd.services.kmod-static-nodes =
242+ { environment.MODULE_DIR = "/run/booted-system/kernel-modules/lib/modules";
243 };
244245 lib.kernelConfig = {
+39-2
nixos/modules/system/boot/modprobe.nix
···89 options = {
100000000000000000000000000000000000011 boot.blacklistedKernelModules = mkOption {
12 type = types.listOf types.str;
13 default = [];
···52 '';
53 environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
5455- environment.systemPackages = [ pkgs.kmod ];
5657 system.activationScripts.modprobe =
58 ''
···60 # in the right location in the Nix store for kernel modules).
61 # We need this when the kernel (or some module) auto-loads a
62 # module.
63- echo ${pkgs.kmod}/bin/modprobe > /proc/sys/kernel/modprobe
64 '';
006566 };
67
···89 options = {
1011+ system.sbin.modprobe = mkOption {
12+ internal = true;
13+ default = pkgs.stdenv.mkDerivation {
14+ name = "modprobe";
15+ buildCommand = ''
16+ mkdir -p $out/bin
17+ for i in ${pkgs.kmod}/sbin/*; do
18+ name=$(basename $i)
19+ echo "$text" > $out/bin/$name
20+ echo 'exec '$i' "$@"' >> $out/bin/$name
21+ chmod +x $out/bin/$name
22+ done
23+ ln -s bin $out/sbin
24+ '';
25+ text =
26+ ''
27+ #! ${pkgs.stdenv.shell}
28+ export MODULE_DIR=/run/current-system/kernel-modules/lib/modules
29+30+ # Fall back to the kernel modules used at boot time if the
31+ # modules in the current configuration don't match the
32+ # running kernel.
33+ if [ ! -d "$MODULE_DIR/$(${pkgs.coreutils}/bin/uname -r)" ]; then
34+ MODULE_DIR=/run/booted-system/kernel-modules/lib/modules/
35+ fi
36+37+ '';
38+ meta.priority = 4;
39+ };
40+ description = ''
41+ Wrapper around modprobe that sets the path to the modules
42+ tree.
43+ '';
44+ };
45+46 boot.blacklistedKernelModules = mkOption {
47 type = types.listOf types.str;
48 default = [];
···87 '';
88 environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
8990+ environment.systemPackages = [ config.system.sbin.modprobe pkgs.kmod ];
9192 system.activationScripts.modprobe =
93 ''
···95 # in the right location in the Nix store for kernel modules).
96 # We need this when the kernel (or some module) auto-loads a
97 # module.
98+ echo ${config.system.sbin.modprobe}/sbin/modprobe > /proc/sys/kernel/modprobe
99 '';
100+101+ environment.sessionVariables.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules";
102103 };
104
···93 echo "stripping FHS paths in \`$mf'..."
94 sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g'
95 done
96- sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|'
97 '';
9899 configurePhase = ''
···188 find -empty -type d -delete
189190 # Remove reference to kmod
191- sed -i Makefile -e 's|= ${kmod}/bin/depmod|= depmod|'
192 '' else optionalString installsFirmware ''
193 make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
194 $installFlags "''${installFlagsArray[@]}"
···93 echo "stripping FHS paths in \`$mf'..."
94 sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g'
95 done
96+ sed -i Makefile -e 's|= depmod|= ${kmod}/sbin/depmod|'
97 '';
9899 configurePhase = ''
···188 find -empty -type d -delete
189190 # Remove reference to kmod
191+ sed -i Makefile -e 's|= ${kmod}/sbin/depmod|= depmod|'
192 '' else optionalString installsFirmware ''
193 make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
194 $installFlags "''${installFlagsArray[@]}"
+1-1
pkgs/os-specific/linux/kmod/aggregator.nix
···21 # kernel version number, otherwise depmod will use `uname -r'.
22 if test -w $out/lib/modules/$kernelVersion; then
23 rm -f $out/lib/modules/$kernelVersion/modules.*
24- ${kmod}/bin/depmod -b $out -a $kernelVersion
25 fi
26 '';
27}
···21 # kernel version number, otherwise depmod will use `uname -r'.
22 if test -w $out/lib/modules/$kernelVersion; then
23 rm -f $out/lib/modules/$kernelVersion/modules.*
24+ ${kmod}/sbin/depmod -b $out -a $kernelVersion
25 fi
26 '';
27}
···1+diff -ru -x '*~' kmod-17-orig/libkmod/libkmod.c kmod-17/libkmod/libkmod.c
2+--- kmod-17-orig/libkmod/libkmod.c 2014-04-01 12:40:37.161940089 +0200
3++++ kmod-17/libkmod/libkmod.c 2014-04-17 13:47:15.871441987 +0200
4+@@ -201,7 +201,7 @@
0000000000000000000000000000000000000005 static char *get_kernel_release(const char *dirname)
6 {
7 struct utsname u;
···1011 if (dirname != NULL)
12 return path_make_absolute_cwd(dirname);
13+@@ -209,7 +209,10 @@
14 if (uname(&u) < 0)
15 return NULL;
1617- if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
18++ if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
19++ dirname_prefix = dirname_default_prefix;
00000000020+
21++ if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
22+ return NULL;
000000000000000000000002324 return p;
25+diff -ru -x '*~' kmod-17-orig/tools/static-nodes.c kmod-17/tools/static-nodes.c
26+--- kmod-17-orig/tools/static-nodes.c 2013-12-17 22:05:42.159047316 +0100
27++++ kmod-17/tools/static-nodes.c 2014-04-17 13:51:17.945974320 +0200
28+@@ -159,6 +159,7 @@
000000000000000000000029 FILE *in = NULL, *out = NULL;
30 const struct static_nodes_format *format = &static_nodes_format_human;
31+ int r, ret = EXIT_SUCCESS;
32++ char *dirname_prefix;
03334+ for (;;) {
35+ int c, idx = 0, valid;
36+@@ -211,16 +212,19 @@
00037 goto finish;
38 }
39+40- snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
41++ if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
42++ dirname_prefix = "/lib/modules";
43++
44++ snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
0045 in = fopen(modules, "re");
46 if (in == NULL) {
47 if (errno == ENOENT) {
48- fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
49- kernel.release);
50++ fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
51++ dirname_prefix, kernel.release);
52 ret = EXIT_SUCCESS;
53 } else {
54- fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
55- kernel.release);
56++ fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
57++ dirname_prefix, kernel.release);
58 ret = EXIT_FAILURE;
59 }
60 goto finish;
+2-1
pkgs/stdenv/darwin/make-bootstrap-tools.nix
···27 # C standard library stuff
28 cp -d ${darwin.Libsystem}/lib/*.o $out/lib/
29 cp -d ${darwin.Libsystem}/lib/*.dylib $out/lib/
03031 # Resolv is actually a link to another package, so let's copy it properly
32 rm $out/lib/libresolv.9.dylib
···90 cp -d ${xz.out}/lib/liblzma*.* $out/lib
9192 # Copy binutils.
93- for i in as ld ar ranlib nm strip otool install_name_tool dsymutil lipo; do
94 cp ${darwin.cctools}/bin/$i $out/bin
95 done
96
···27 # C standard library stuff
28 cp -d ${darwin.Libsystem}/lib/*.o $out/lib/
29 cp -d ${darwin.Libsystem}/lib/*.dylib $out/lib/
30+ cp -d ${darwin.Libsystem}/lib/system/*.dylib $out/lib/
3132 # Resolv is actually a link to another package, so let's copy it properly
33 rm $out/lib/libresolv.9.dylib
···91 cp -d ${xz.out}/lib/liblzma*.* $out/lib
9293 # Copy binutils.
94+ for i in as ld ar ranlib nm strip otool install_name_tool dsymutil; do
95 cp ${darwin.cctools}/bin/$i $out/bin
96 done
97