Skip to content

Commit 4e70bd7

Browse files
authored
Merge pull request #37 from numtide/graphics-module-initrd
Add the graphics card driver modules to the initrd
2 parents 2c3ac40 + 827665f commit 4e70bd7

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

lib/lib.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ let
2323
vendor_name == name
2424
) cpus;
2525

26+
collectDrivers = list: lib.foldl' (lst: value: lst ++ value.driver_modules or [ ]) [ ] list;
27+
stringSet = list: builtins.attrNames (builtins.groupBy lib.id list);
2628
in
2729
{
28-
inherit hasCpu;
30+
inherit hasCpu collectDrivers stringSet;
2931
hasAmdCpu = hasCpu "AuthenticAMD";
3032
hasIntelCpu = hasCpu "GenuineIntel";
3133
}

modules/nixos/boot.nix

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{ lib, config, ... }:
22
let
3+
facterLib = import ../../lib/lib.nix lib;
34

45
cfg = config.facter.boot;
56
inherit (config.facter) report;
6-
collectDriver = list: lib.foldl' (lst: value: lst ++ value.driver_modules or [ ]) [ ] list;
7-
stringSet = list: builtins.attrNames (builtins.groupBy lib.id list);
87
in
98
{
109
options.facter.boot.enable = lib.mkEnableOption "Enable the Facter Boot module" // {
@@ -14,8 +13,8 @@ in
1413
config =
1514
with lib;
1615
mkIf cfg.enable {
17-
boot.initrd.availableKernelModules = stringSet (
18-
collectDriver (
16+
boot.initrd.availableKernelModules = facterLib.stringSet (
17+
facterLib.collectDrivers (
1918
# Needed if we want to use the keyboard when things go wrong in the initrd.
2019
(report.hardware.usb_controller or [ ])
2120
# A disk might be attached.

modules/nixos/graphics.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{ lib, config, ... }:
2+
let
3+
facterLib = import ../../lib/lib.nix lib;
4+
in
25
{
36
options.facter.graphics.enable = lib.mkEnableOption "Enable the Graphics module" // {
4-
default = builtins.length (config.facter.report.hardware.monitor or []) > 0;
7+
default = builtins.length (config.facter.report.hardware.monitor or [ ]) > 0;
58
};
69

7-
config.hardware.graphics.enable = lib.mkIf config.facter.graphics.enable (lib.mkDefault true);
10+
config = lib.mkIf config.facter.graphics.enable {
11+
hardware.graphics.enable = lib.mkDefault true;
12+
boot.initrd.kernelModules = facterLib.stringSet (
13+
facterLib.collectDrivers (config.facter.report.hardware.graphics_card or [ ])
14+
);
15+
};
816
}

0 commit comments

Comments
 (0)