Hey oberstal,
I ran into this myself after getting frustrated with GDM always trying to display on the TV I have plugged in (which is usually off) rather than my main monitor. Digging around in gdm.nix
I noticed there is already a pulseaudio config being symlinked into /run/gdm
using systemd.tmpfiles.rules
and figured that pattern would work for monitors.xml
as well.
Here’s what I have in my configuration.nix
and it seems to be working well:
systemd.tmpfiles.rules = [
"L+ /run/gdm/.config/monitors.xml - - - - ${pkgs.writeText "gdm-monitors.xml" ''
<!-- this should all be copied from your ~/.config/monitors.xml -->
<monitors version="2">
<configuration>
<!-- REDACTED -->
</configuration>
</monitors>
''}"
];
Here is where the tmpfiles are set up in gdm.nix
, if you’re curious: https://github.com/NixOS/nixpkgs/blob/cd63096d6d887d689543a0b97743d28995bc9bc3/nixos/modules/services/x11/display-managers/gdm.nix#L152-L160