Kde

KDE 顯示無法在 NixOS 上執行 - Thinkpad P15 Gen 2、NVIDIA RTX A4000

  • March 21, 2022

我正在嘗試在新的 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;
}

來自 display-manager 的日誌位於此 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

如有必要,很高興發布更多日誌或文件,並願意嘗試任何方法來使其正常工作!預先感謝您的任何幫助!

這實際上是由於集成的英特爾顯卡無法與我筆記型電腦中的 Nvidia 卡配合使用。由於集成顯卡只能與模式設置驅動程序一起使用,因此將配置更改為以下修復它:

services.xserver.videoDrivers = [ "modesetting" ]

而不是[ "nvidia" ]. 此外,如 Wiki 中所述,使用 NixOS 中的 PRIME 配置在集成顯卡和 Nvidia 顯卡之間設置解除安裝非常簡單。

引用自:https://unix.stackexchange.com/questions/696191