Hi All, I thought I would share something to help you if you are struggling in getting the GDM login screen to not show on the correct monitor if you have multi monitor setup. you have to first create a monitor.xml file in your /home/username/.config/ folder or this is automatically done and setup when you login with gnome and you set your monitor layout how you want there. Once done. Add the below to your configuration.nix file. Note the areas where you have to change the directory names to your user name first.
{ config, pkgs, ... }:
{
services.xserver.displayManager.gdm.enable = true;
systemd.services.copyGdmMonitorsXml = {
description = "Copy monitors.xml to GDM config";
after = [ "network.target" "systemd-user-sessions.service" "display-manager.service" ];
serviceConfig = {
ExecStart = "${pkgs.bash}/bin/bash -c 'echo \"Running copyGdmMonitorsXml service\" && mkdir -p /run/gdm/.config && echo \"Created /run/gdm/.config directory\" && [ \"/home/your-username/.config/monitors.xml\" -ef \"/run/gdm/.config/monitors.xml\" ] || cp /home/your-username/.config/monitors.xml /run/gdm/.config/monitors.xml && echo \"Copied monitors.xml to /run/gdm/.config/monitors.xml\" && chown gdm:gdm /run/gdm/.config/monitors.xml && echo \"Changed ownership of monitors.xml to gdm\"'";
Type = "oneshot";
};
wantedBy = [ "multi-user.target" ];
};
}
once this is done run:
sudo nixos-rebuild switch
sudo systemctl restart display-manager
for most this should be it, however I had to do a reboot for it to show.
if still having issues follow the below…
Ensure Permissions: Make sure the GDM user has the necessary permissions to read the monitors.xml file. You can do this by running the following commands:
sudo chown gdm:gdm /home/user-name/.config/monitors.xml
sudo chmod 644 /home/user-name/.config/monitors.xml
Manually Copy the monitors.xml File: As a temporary measure, manually copy the monitors.xml file to the GDM configuration directory to see if it resolves the issue. Run the following commands:
sudo mkdir -p /run/gdm/.config
sudo cp /home/user-name/.config/monitors.xml /run/gdm/.config/monitors.xml
sudo chown gdm:gdm /run/gdm/.config/monitors.xml
Restart GDM: Restart the GDM service:
sudo systemctl restart display-manager
then do a final reboot too.