What is the proper way to configure your monitors in Nix/NixOS? I have two monitors connected to my main home machine, one Ultrawide 100Hz monitor and my TV. Usually, that TV is turned off. By default it seems Xorg selects my TV as my primary screen, and sets my Ultrawide to 60Hz.
I can, of course, use
xrandr --output HDMI-1 --off --output DP-1 --primary --mode 3440x1440 --rate 100 to fix this, and that works just fine, but is there any proper way to configure this without having to do this on every login?
I’ve tried using
services.xserver.displayManager.setupCommands in combination with the
xrandr command above, but that didn’t actually do anything.
I’ve also tried using
services.xserver.xrandrHeads. This one gets me a little further along, because it allows me to select my primary monitor through
services.xserver.xrandrHeads.*.primary = true, but that still doesn’t allow me to disable the TV or set my Ultrawide’s refresh rate. The documentation says that
services.xserver.xrandrHeads.*.monitorConfig takes any configuration listen in the
MONITOR section of
man 5 xorg.conf, but there are no relevant configuration options in that section (at least that I can find).
Ideally, I want to be able to:
- Set my Ultrawide as my primary display
- Set the refresh rate of the Ultrawide to 100Hz
- Mirror my ultrawide on the TV (so that it displays my screen on the TV when turned on, but keeps everything locked to my ultrawide monitor, so that for example my mouse doesn’t continue to scroll past the screen boundaries)
I know that theoretically I can invoke
xrandr in some startup script somewhere, but that does not seem to fit with the spirit of Nix and NixOS (that’s something I’d do if I were on Arch/Gentoo), so I’m looking for a proper solution here.
I previously just dealt with it by making changes in GNOMEs configuration settings, but it’s really annoying now that I’m trying out my new Xmonad setup.