I recently started using NixOS on a Lenovo X1 extreme laptop with an Intel and a Nvidia graphic card. Preferably I want to use Sway as tiling window manager. When I attach an external monitor with HDMI cable I experience flickering. It seems similar to what @nomadics describe here and is indeed very annoying.
As I am using Sway instead of Hyprland (both are built on Wayland) I decided to create a new topic instead of commenting on the topic linked above. However I suspect, these issues are related, and this could be an issue with the nvidia graphic card driver - but I am reaching the edge of my current knowledge here and will appreciate any further help.
Temporarily I have switched to Gnome that also runs on xorg. Here I do not experience any flickering on the external monitor.
Graphic card info:
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Alder Lake-P Integrated Graphics Controller (rev 0c)
01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050 Ti Mobile] (rev a1)
$ lcpci | less
/VGA
00:02.0 VGA compatible controller: Intel Corporation Alder Lake-P Integrated Graphics Controller (rev 0c) (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 22f8
Flags: bus master, fast devsel, latency 0, IRQ 189, IOMMU group 0
Memory at 625b000000 (64-bit, non-prefetchable) [size=16M]
Memory at 4000000000 (64-bit, prefetchable) [size=512M]
I/O ports at 4000 [size=64]
Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
Capabilities: <access denied>
Kernel driver in use: i915
Kernel modules: i915
01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050 Ti Mobile] (rev a1) (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 22f8
Flags: bus master, fast devsel, latency 0, IRQ 190, IOMMU group 16
Memory at b3000000 (32-bit, non-prefetchable) [size=16M]
Memory at 6000000000 (64-bit, prefetchable) [size=8G]
Memory at 6200000000 (64-bit, prefetchable) [size=32M]
I/O ports at 3000 [size=128]
Expansion ROM at b4080000 [virtual] [disabled] [size=512K]
Capabilities: <access denied>
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia
System info:
$ nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 6.1.39, NixOS, 23.11 (Tapir), 23.11.20230724.b12803b`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.15.1`
- channels(root): `"nixos-23.05"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Relevant snippets from configuration.nix
regarding nvidia and sway installation:
environment.loginShellInit = ''
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
sway --unsupported-gpu -V > .sway-log 2>&1
fi
'';
nixpkgs.config.allowUnfree = true;
hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable;
nvidiaPersistenced = true;
modesetting.enable = true;
prime = {
sync.enable = true;
nvidiaBusId = "PCI:1:0:0";
intelBusId = "PCI:0:2:0";
};
};
services.xserver = {
enable = true;
videoDrivers = [
"nvidia"
];
};
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
extraPackages = with pkgs; [
linux-firmware
swaylock
swayidle
alacritty
i3status-rust
brightnessctl
wayland
];
extraSessionCommands = ''
export MOZ_ENABLE_WAYLAND=1
export WLR_DRM_NO_MODIFIERS=1
export WLR_DRM_DEVICES=/dev/dri/card0
'';
};