Skip to content

Commit

Permalink
Merge pull request #37 from numtide/graphics-module-initrd
Browse files Browse the repository at this point in the history
Add the graphics card driver modules to the initrd
  • Loading branch information
brianmcgee authored Sep 25, 2024
2 parents 2c3ac40 + 827665f commit 4e70bd7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ let
vendor_name == name
) cpus;

collectDrivers = list: lib.foldl' (lst: value: lst ++ value.driver_modules or [ ]) [ ] list;
stringSet = list: builtins.attrNames (builtins.groupBy lib.id list);
in
{
inherit hasCpu;
inherit hasCpu collectDrivers stringSet;
hasAmdCpu = hasCpu "AuthenticAMD";
hasIntelCpu = hasCpu "GenuineIntel";
}
7 changes: 3 additions & 4 deletions modules/nixos/boot.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{ lib, config, ... }:
let
facterLib = import ../../lib/lib.nix lib;

cfg = config.facter.boot;
inherit (config.facter) report;
collectDriver = list: lib.foldl' (lst: value: lst ++ value.driver_modules or [ ]) [ ] list;
stringSet = list: builtins.attrNames (builtins.groupBy lib.id list);
in
{
options.facter.boot.enable = lib.mkEnableOption "Enable the Facter Boot module" // {
Expand All @@ -14,8 +13,8 @@ in
config =
with lib;
mkIf cfg.enable {
boot.initrd.availableKernelModules = stringSet (
collectDriver (
boot.initrd.availableKernelModules = facterLib.stringSet (
facterLib.collectDrivers (
# Needed if we want to use the keyboard when things go wrong in the initrd.
(report.hardware.usb_controller or [ ])
# A disk might be attached.
Expand Down
12 changes: 10 additions & 2 deletions modules/nixos/graphics.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{ lib, config, ... }:
let
facterLib = import ../../lib/lib.nix lib;
in
{
options.facter.graphics.enable = lib.mkEnableOption "Enable the Graphics module" // {
default = builtins.length (config.facter.report.hardware.monitor or []) > 0;
default = builtins.length (config.facter.report.hardware.monitor or [ ]) > 0;
};

config.hardware.graphics.enable = lib.mkIf config.facter.graphics.enable (lib.mkDefault true);
config = lib.mkIf config.facter.graphics.enable {
hardware.graphics.enable = lib.mkDefault true;
boot.initrd.kernelModules = facterLib.stringSet (
facterLib.collectDrivers (config.facter.report.hardware.graphics_card or [ ])
);
};
}

0 comments on commit 4e70bd7

Please sign in to comment.