1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6
7 ###### interface
8
9 options = {
10
11 boot.blacklistedKernelModules = mkOption {
12 type = types.listOf types.str;
13 default = [];
14 example = [ "cirrusfb" "i2c_piix4" ];
15 description = lib.mdDoc ''
16 List of names of kernel modules that should not be loaded
17 automatically by the hardware probing code.
18 '';
19 };
20
21 boot.extraModprobeConfig = mkOption {
22 default = "";
23 example =
24 ''
25 options parport_pc io=0x378 irq=7 dma=1
26 '';
27 description = lib.mdDoc ''
28 Any additional configuration to be appended to the generated
29 {file}`modprobe.conf`. This is typically used to
30 specify module options. See
31 {manpage}`modprobe.d(5)` for details.
32 '';
33 type = types.lines;
34 };
35
36 };
37
38
39 ###### implementation
40
41 config = mkIf (!config.boot.isContainer) {
42
43 environment.etc."modprobe.d/ubuntu.conf".source = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
44
45 environment.etc."modprobe.d/nixos.conf".text =
46 ''
47 ${flip concatMapStrings config.boot.blacklistedKernelModules (name: ''
48 blacklist ${name}
49 '')}
50 ${config.boot.extraModprobeConfig}
51 '';
52 environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
53
54 environment.etc."modprobe.d/systemd.conf".source = "${config.systemd.package}/lib/modprobe.d/systemd.conf";
55
56 environment.systemPackages = [ pkgs.kmod ];
57
58 system.activationScripts.modprobe = stringAfter ["specialfs"]
59 ''
60 # Allow the kernel to find our wrapped modprobe (which searches
61 # in the right location in the Nix store for kernel modules).
62 # We need this when the kernel (or some module) auto-loads a
63 # module.
64 echo ${pkgs.kmod}/bin/modprobe > /proc/sys/kernel/modprobe
65 '';
66
67 };
68
69}