KDE 显示屏无法在 NixOS 上运行 - Thinkpad P15 Gen 2、NVIDIA RTX A4000

KDE 显示屏无法在 NixOS 上运行 - Thinkpad P15 Gen 2、NVIDIA RTX A4000

我正在尝试在新的 Thinkpad P15 Gen 2 上安装 NixOS,但桌面环境无法在屏幕上显示任何内容。每次打开或重新启动时,屏幕都会保持黑色,直到我按 ctrl+alt+F4 进入 shell。我正在尝试使用 KDE Plasma 5,但如果其他 DE 效果更好,我愿意尝试。我使用了带有 KDE 的安装程序 ISO,它能够显示图形显示和所有内容。然后在我的分区上安装后,我无法获得图形显示。

这是我的configuration.nix(当前频道是nixos/21.11):

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.kernelPackages = pkgs.linuxPackages_5_16;

  networking.hostName = "fins-thinkpad"; # Define your hostname.
  
  networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.

  # Nvidia drivers unfree
  nixpkgs.config.allowUnfree = true;

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the Plasma 5 Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.opengl.enable = true;

  users.users.finley = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
  };

  environment.systemPackages = with pkgs; [
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    firefox
  ];

  system.stateVersion = "22.05"; # Did you read the comment?
}

和我的hardware-configuration.nix

{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/7e6bcba1-25e7-43f5-8dd2-1458d863c0c4";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/19A7-C717";
      fsType = "vfat";
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/14412169-fb90-4e0c-ae3f-735c817b8cf3"; }
    ];

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = lib.mkDefault false;
  networking.interfaces.enp11s0.useDHCP = lib.mkDefault true;
  networking.interfaces.wlp9s0.useDHCP = lib.mkDefault true;

  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
  # high-resolution display
  hardware.video.hidpi.enable = lib.mkDefault true;
}

来自显示管理器的日志位于此 Pastebin 原始链接上:https://pastebin.com/raw/YycVPVVd

这是输出lspci -k | grep -A3 'VGA'

00:02.0 VGA compatible controller: Intel Corporation Device 9a70 (rev 01)
    Subsystem: Lenovo Device 22d8
    Kernel driver in use: i915
    Kernel modules: i915
--
01:00.0 VGA compatible controller: NVIDIA Corporation Device 24b7 (rev a1)
    Subsystem: Lenovo Device 22d8
    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

如有必要,很乐意发布更多日志或文件,并愿意尝试任何方法来使其正常工作!预先感谢您的任何帮助!

答案1

这实际上是由于我的笔记本电脑中的集成英特尔显卡与 Nvidia 卡不能很好地配合而导致的。由于集成显卡只能与模式设置驱动程序一起使用,因此将配置更改为以下内容可以解决此问题:

services.xserver.videoDrivers = [ "modesetting" ]

代替[ "nvidia" ]。此外,使用 NixOS 中的 PRIME 配置在集成显卡和 Nvidia 显卡之间设置卸载非常简单正如维基百科中所解释的

相关内容