Failed to create session: Unit dbus-org.freedesktop.login1.service not found

I’ve been trying to use SwayWM instead of i3 (mainly for hardware reasons, amdgpu with my laptop has a known issue for recovring from sleep while beeing on a Xorg session).

Sway is working really well, but I cannot start it on boot properly. I do not want to start a displaymanager because they are not working really well with Wayland sessions.

I currently start Sway this way :

  programs.sway = {
    enable = true;
    extraPackages = with pkgs; [
      swaylock swayidle xwayland termite
      mako grim slurp wl-clipboard wf-recorder
    ];
    extraSessionCommands = ''
      export SDL_VIDEODRIVER=wayland
      export QT_QPA_PLATFORM=wayland
      export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
      export _JAVA_AWT_WM_NONREPARENTING=1
      export MOZ_ENABLE_WAYLAND=1
    '';
  };

  systemd.defaultUnit = "graphical.target";
  systemd.services.sway = {
    enable = true;
    wants = [ "systemd-machined.service" ];
    aliases = [ "display-manager.service" ];
    after =  [
      "rc-local.service"
      "systemd-machined.service"
      "systemd-user-sessions.service"
      "plymouth-quit.service"
      "plymouth-start.service"
    ];
    serviceConfig = {
      ExecStartPre = "${config.system.path}/bin/chvt ${sway.tty}";
      ExecStart = "${pkgs.dbus}/bin/dbus-launch --exit-with-session ${pkgs.sway}/bin/sway";
      TTYPath = "/dev/tty${sway.tty}";
      TTYReset = "yes";
      TTYVHangup = "yes";
      TTYVTDisallocate = "yes";
      PAMName = "login";
      User = sway.username;
      WorkingDirectory = "/home/${sway.username}";
      StandardInput = "tty";
      StandardError = "journal";
      StandardOutput = "journal";
      Restart = "no";
    };
  };

I mainly used the gdm nix derivation as a source for creating this systemd unit.

But when it starts, it crashes completly at the first try :

Dec 01 10:14:29 ely-lenovo systemd[1]: Starting sway.service...
Dec 01 10:14:29 ely-lenovo systemd[1034]: pam_unix(login:session): session opened for user ely by (uid=0)
Dec 01 10:14:29 ely-lenovo systemd[1034]: pam_systemd(login:session): Failed to create session: Unit dbus-org.freedesktop.login1.service not found.
Dec 01 10:14:29 ely-lenovo systemd[1]: Started sway.service.
Dec 01 10:14:29 ely-lenovo systemd[1036]: pam_unix(login:session): session opened for user ely by (uid=0)
Dec 01 10:14:29 ely-lenovo systemd[1036]: pam_systemd(login:session): Failed to create session: Unit dbus-org.freedesktop.login1.service not found.
Dec 01 10:14:29 ely-lenovo dbus-launch[1036]: XDG_RUNTIME_DIR is not set in the environment. Aborting.
Dec 01 10:14:29 ely-lenovo systemd[1]: sway.service: Main process exited, code=exited, status=1/FAILURE
Dec 01 10:14:32 ely-lenovo systemd[1]: sway.service: Failed with result 'exit-code'.

If I put Restart to on-failure it works correctly at a second try. I conclude that the session starts a bit too early in the process, but I cannot figure out what I’m supposed to wait for. Any ideas ?