Hello!
I am a new nixos user having some difficulty with display managers, so apologies if my descriptions aren’t helpful, and just let me know what additional information I should provide. I’m running nixos version 26.05, I have unfree nvidia drivers enabled as described on the wiki (https://nixos.wiki/wiki/Nvidia), and I’m using sway (enabled both as a nixos module and a home-manager module).
What currently happens:
Every time I log in or out, my monitor turns black, flickers, and then turns back on as normal. The sequence takes about 2-3 seconds. I recognize this exact behavior from back when I had windows installed: it happens every time I change the resolution or refresh rate on my monitor. This behavior started immediately after I enabled the nvidia drivers.
What should happen:
When logging in, sway should load immediately without the monitor going black. I know this behavior is possible since it’s what happened before I had the nvidia drivers enabled. When logging out, sway should immediately lock, and the log in screen should immediately appear. sway should also run at 2560x1440@143.856Hz.
What I’ve tried:
I’ve tried disabling the nvidia drivers, but this leads to quickshell and noctalia crashing when browsing certain pages on Firefox (YouTube). With the nvidia drivers install, I’ve tried:
- Enabling services such as
greetdto get the login screen to run at 2560x1440@143.856Hz. - Setting
boot.kernelParams = [ “video=DP-1:2560x1440@143.856” ];to get the kernel to run at 2560x1440@143.856Hz. - Launching
greetdin its own sway session configured to run at 2560x1440@143.856Hz.
Unfortunately, none of the above have worked out for me. I’ve copied the relevant portions of my configuration below. Thanks in advance for any help!
As a nixos module, I have:
# display.nix
{ config, pkgs, lib, ... }:
let
res = "2560x1440";
rate = "143.856";
greetdSwayConfig = pkgs.writeText "greetd-sway-config" ''
output "DP-1" mode ${res}@${rate}Hz
exec "${pkgs.greetd.regreet}/bin/regreet; swaymsg exit"
'';
in {
programs.sway.enable = true;
security.polkit.enable = true; # needed for `sway`
boot.kernelParams = [
"video=DP-1:${res}@${rate}"
];
programs.regreet.enable = true;
services.greetd = {
enable = true;
settings.default_session.command = lib.mkForce "${pkgs.sway}/bin/sway --unsupported-gpu --config ${greetdSwayConfig}";
};
}
As a home-manager module, I have:
# sway.nix
{ config, lib, pkgs, ... }: {
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true; # recommended by the nixos wiki to fix common issue with GTK 3 apps
extraOptions = [
"--unsupported-gpu" # since sway doesn't support unfree nvidia drivers
];
config = {
terminal = "kitty";
startup = [
{
command = "swaymsg workspace number 1";
always = false;
}
{ command = "noctalia-shell"; }
];
output = {
"DP-1" = {
mode = "2560x1440@143.856Hz";
};
};
};
};
}
The nvidia drivers are also enabled through nixos modules:
# nvidia.nix
# (almost) straight copy-paste from https://nixos.wiki/wiki/Nvidia.
{ config, lib, pkgs, ... }: {
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"nvidia-x11"
"nvidia-settings"
"nvidia-persistenced"
];
# Enable OpenGL
hardware.graphics = {
enable = true;
};
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
}