diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index e9d22178..df7fcc80 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -113,9 +113,26 @@ in }; # Make sure the WSLg X11 socket is available if /tmp is mounted to something else - fileSystems."/tmp/.X11-unix/X0" = { - device = "${cfg.wslConf.automount.root}/wslg/.X11-unix/X0"; - options = [ "bind" ]; + systemd.mounts = [rec { + description = "Mount WSLg X11 socket"; + what = "${cfg.wslConf.automount.root}/wslg/.X11-unix/X0"; + where = "/tmp/.X11-unix/X0"; + type = "none"; + options = "bind"; + wantedBy = [ "local-fs.target" ]; + after = [ "nixos-wsl-migration-x11mount.service" ]; + wants = after; + }]; + # Remove symbolic link for WSLg X11 socket, which was created by NixOS-WSL until 2024-02-24 + systemd.services.nixos-wsl-migration-x11mount = { + description = "Remove /tmp/.X11-unix symlink if present"; + before = [ "tmp-.X11\x2dunix-X0.mount" ]; + unitConfig.ConditionPathIsSymbolicLink = "/tmp/.X11-unix"; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.coreutils}/bin/rm /tmp/.X11-unix"; + }; }; # dhcp is handled by windows