我正在尝试在新的 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 卡配合使用。由于集成显卡只能与模式设置驱动程序一起使用,因此将配置更改为以下修复它:
而不是
[ "nvidia" ]
. 此外,如 Wiki 中所述,使用 NixOS 中的 PRIME 配置在集成显卡和 Nvidia 显卡之间设置卸载非常简单。