Unverified Commit 1d0dd699 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

nixos/facter: add graphics hardware detection (#458177)

parents f3a9c3ad 484feccb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
  imports = [
    ./disk.nix
    ./firmware.nix
    ./graphics
    ./keyboard.nix
    ./networking
    ./system.nix
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ in
    '';
  };

  config = {
  config = lib.mkIf (config.hardware.facter.reportPath != null) {
    boot.initrd.availableKernelModules = config.hardware.facter.detected.boot.disk.kernelModules;
  };
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ let
  hasIntelCpu = facterLib.hasIntelCpu report;
in
{
  config = lib.mkIf isBaremetal {
  config = lib.mkIf (config.hardware.facter.reportPath != null && isBaremetal) {
    # none (e.g. bare-metal)
    # provide firmware for devices that might not have been detected by nixos-facter
    hardware.enableRedistributableFirmware = lib.mkDefault true;
+18 −0
Original line number Diff line number Diff line
{ lib, config, ... }:
let
  facterLib = import ../lib.nix lib;
  cfg = config.hardware.facter.detected.graphics.amd;
in
{
  options.hardware.facter.detected.graphics = {
    amd.enable = lib.mkEnableOption "Enable the AMD Graphics module" // {
      default = builtins.elem "amdgpu" (
        facterLib.collectDrivers (config.hardware.facter.report.hardware.graphics_card or [ ])
      );
      defaultText = "hardware dependent";
    };
  };
  config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) {
    services.xserver.videoDrivers = [ "modesetting" ];
  };
}
+42 −0
Original line number Diff line number Diff line
{ lib, config, ... }:
let
  facterLib = import ../lib.nix lib;
  cfg = config.hardware.facter.detected.graphics;
in
{
  imports = [
    ./amd.nix
  ];
  options.hardware.facter.detected = {
    graphics.enable = lib.mkEnableOption "Enable the Graphics module" // {
      default = builtins.length (config.hardware.facter.report.hardware.monitor or [ ]) > 0;
      defaultText = "hardware dependent";
    };
    boot.graphics.kernelModules = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      # We currently don't auto import nouveau, in case the user might want to use the proprietary nvidia driver,
      # We might want to change this in future, if we have a better idea, how to handle this.
      default = lib.remove "nouveau" (
        lib.uniqueStrings (
          facterLib.collectDrivers (config.hardware.facter.report.hardware.graphics_card or [ ])
        )
      );
      defaultText = "hardware dependent";
      description = ''
        List of kernel modules to load at boot for the graphics card.
      '';
    };
  };

  config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) (
    {
      boot.initrd.kernelModules = config.hardware.facter.detected.boot.graphics.kernelModules;
    }
    // (
      if lib.versionOlder lib.version "24.11pre" then
        { hardware.opengl.enable = lib.mkDefault true; }
      else
        { hardware.graphics.enable = lib.mkDefault true; }
    )
  );
}
Loading