2014-04-14 16:26:48 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2009-11-08 09:01:53 +00:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-11-08 09:01:53 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2023-01-17 13:01:47 +01:00
|
|
|
boot.modprobeConfig.enable =
|
|
|
|
mkEnableOption "modprobe config. This is useful for systems like containers which do not require a kernel"
|
|
|
|
// {
|
2022-10-26 17:05:14 +02:00
|
|
|
default = true;
|
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2024-12-02 08:58:27 -08:00
|
|
|
boot.modprobeConfig.useUbuntuModuleBlacklist =
|
|
|
|
mkEnableOption "Ubuntu distro's module blacklist"
|
|
|
|
// {
|
2024-02-21 01:10:32 +00:00
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
2009-11-08 09:01:53 +00:00
|
|
|
boot.blacklistedKernelModules = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
type = types.listOf types.str;
|
2009-11-08 09:01:53 +00:00
|
|
|
default = [ ];
|
|
|
|
example = [
|
|
|
|
"cirrusfb"
|
|
|
|
"i2c_piix4"
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
List of names of kernel modules that should not be loaded
|
|
|
|
automatically by the hardware probing code.
|
|
|
|
'';
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-11-08 09:01:53 +00:00
|
|
|
boot.extraModprobeConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
options parport_pc io=0x378 irq=7 dma=1
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Any additional configuration to be appended to the generated
|
|
|
|
{file}`modprobe.conf`. This is typically used to
|
|
|
|
specify module options. See
|
2020-02-27 16:53:21 -08:00
|
|
|
{manpage}`modprobe.d(5)` for details.
|
2009-11-08 09:01:53 +00:00
|
|
|
'';
|
2013-03-12 05:51:45 -04:00
|
|
|
type = types.lines;
|
2009-11-08 09:01:53 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-11-08 09:01:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2022-10-26 17:05:14 +02:00
|
|
|
config = mkIf config.boot.modprobeConfig.enable {
|
2009-11-08 09:01:53 +00:00
|
|
|
|
2024-02-21 01:10:32 +00:00
|
|
|
environment.etc."modprobe.d/ubuntu.conf" =
|
|
|
|
mkIf config.boot.modprobeConfig.useUbuntuModuleBlacklist
|
|
|
|
{
|
|
|
|
source = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
|
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2014-07-31 22:09:10 +02:00
|
|
|
environment.etc."modprobe.d/nixos.conf".text = ''
|
|
|
|
${flip concatMapStrings config.boot.blacklistedKernelModules (name: ''
|
|
|
|
blacklist ${name}
|
|
|
|
'')}
|
|
|
|
${config.boot.extraModprobeConfig}
|
|
|
|
'';
|
2015-09-05 17:11:03 -06:00
|
|
|
environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
|
2009-11-08 09:01:53 +00:00
|
|
|
|
2022-05-05 13:23:32 +02:00
|
|
|
environment.etc."modprobe.d/systemd.conf".source =
|
|
|
|
"${config.systemd.package}/lib/modprobe.d/systemd.conf";
|
2022-02-22 17:17:14 +01:00
|
|
|
|
2016-08-14 13:00:52 +03:00
|
|
|
environment.systemPackages = [ pkgs.kmod ];
|
2012-06-15 14:18:26 -04:00
|
|
|
|
2018-02-05 21:04:40 +01:00
|
|
|
system.activationScripts.modprobe = stringAfter [ "specialfs" ] ''
|
2010-09-13 15:41:38 +00:00
|
|
|
# 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.
|
2016-08-14 13:00:52 +03:00
|
|
|
echo ${pkgs.kmod}/bin/modprobe > /proc/sys/kernel/modprobe
|
2010-09-13 15:41:38 +00:00
|
|
|
'';
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-11-08 09:08:50 +00:00
|
|
|
};
|
2009-11-08 09:01:53 +00:00
|
|
|
|
2009-11-08 09:08:50 +00:00
|
|
|
}
|