Please post working xrdp setting in configuration.nix

Hi,
I use NixOS 20.03.

XRDP doesnt work as advertised
https://nixos.wiki/wiki/Remote_Desktop

Would somone please post a working configuration.nix?

When I specify the ICEW as in the link and log in via RDP, the system just asks for username and password and after that I just get a teal background screen with no buton

I am puzzled that there aren’t many posting about XRDP in NixOS. Do people just use SSH or X window manager and not many people use XRDP? Or do people just use something like the VNCServer?

I just tested it. It works fine here. I am using xorg.

I copy/pasted it straight from the wiki:

services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
networking.firewall.allowedTCPPorts = [ 3389 ];

Here is the full configuration.nix from the VM I use for testing random nixos stuff. It isn’t very clean :cowboy_hat_face:

configuration.nix
# The vm used for testing

{ config, pkgs, ... }:

let
  unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
in {
  imports =
    [ 
      ./modules/common.nix
      ./modules/zsh.nix
      ./modules/sddm-theme.nix
      ./modules/vmware.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Enable the KDE Desktop Environment.
  services.xserver.desktopManager.plasma5.enable = true;
  services.xserver.displayManager.sddm = {enable = true; extraConfig = ''
  [General]
  InputMethod=
'';};
  services.sddmTheme = {enable = true; backgroundFile = /wallpapers/slimepink.png;};

  networking.interfaces.ens33.useDHCP = true;
  networking.hostName = "nixos";

  environment.systemPackages = with pkgs; [
    unzip
    ffmpeg
    kate
    firefox
    flameshot
    gwenview
    okular
    gimp
    falkon
    (vivaldi.override { proprietaryCodecs = true; enableWidevine = true; })
    smplayer
    vlc
    sayonara
    latte-dock
    appimage-run
    unstable.vscodium
    inxi
    lm_sensors
    glxinfo
    mpv
  ];


  # Open ports in the firewall.
  networking.firewall.enable = true;
  networking.firewall.allowedTCPPorts = [ 3389 ];
  # networking.firewall.allowedUDPPorts = [ ... ];

  services.printing.enable = true;

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.layout = "us";
  # services.xserver.xkbOptions = "eurosign:e";

  users.users.dalto = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
  };

  system.stateVersion = "20.03"; # Did you read the comment?

  nixpkgs.config.allowUnfree = true;

  # zfs
  boot.initrd.supportedFilesystems = [ "zfs" ];
  boot.zfs.devNodes = "/dev/disk/by-partuuid";
  services.zfs.autoScrub.enable = true;
  networking.hostId = "6b4fb61d";

  # automatic upgrades
  system.autoUpgrade = {enable = true; allowReboot = true;};

  services.xrdp.enable = true;
  services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
}

Speaking only for myself, I use ssh 90% of the time. When I need a graphical session I usually use my virtualization platform to get access to the console.

1 Like

Thank you so much! Let me try soon! Is it the case that I need to turn off the native X session running with the video caed before I can use the XRDP version, maybe? Anyway, let me try!

I don’t think so. I was able to log into the plasma session via the console and rdp concurrently.

That being said, I didn’t test extensively.

1 Like

@yasu I am using XRDP + remmina (the RDP client) for work extensively. This module should work for 20.03. Hope it helps. Btw, I am using xfce on remote server, haven’t tested the others yet.

1 Like

I have just tried again - using the same configuration, I still get the same old problem - just a teal background screen


This XRDP setting is so frustrating. I have no idea what I am doing wrong.

These are the relevant lines from my /etc/nixos/configuration.nix
``
services.xrdp.enable = true;

services.xrdp.defaultWindowManager = “${pkgs.xterm}/bin/xterm”;

networking.firewall.allowedTCPPorts = [ 3389 ];
``

Would some please post a complete configuration that does work? (Please make it as “declarative” as possible - no missing dependencies or anything)

I don’t care what kind of Window Manger - just please post something that does work (meaning, I can launch programs)

I am so curious why this takes such an effort. Doesn’t almost everybody who runs graphical applications from a remote terminal use XRDP? Or do people use other methods like VNC?

I’ve been using x11vnc which does work but crashes frequently for unknown reasons. x11 forwarding on ssh works with good stability however

It appears that the following is necessary to make it work.

  1. There can only be a single desktopManager. Add multiple lines and XRDP won’t work
services.xserver.desktopManager.gnome3.enable = true;
  1. Even if only a single desktopManager is specified as above, only ICEWM would work. No other desktopManager will work (other than the default xterm).
  services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; 

In the github link below, anything that includes:

config.services.xserver.displayManager.session.script

will fail, because the daisy chaining by “.” (dot) will fail in the middle of the expression.

The expression fails because one of the elements joined by “.” is a list of 2 elements, instead of a single set.

A working solution for KDE has been found (https://github.com/NixOS/nixpkgs/issues/57717#issuecomment-698297970):

  services.xserver.enable = true;
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;


  services.xrdp.enable = true;
  services.xrdp.defaultWindowManager = "startplasma-x11";
  networking.firewall.allowedTCPPorts = [ 3389 ];

Make sure to reboot after rebuilding.

1 Like

Thank you​:smile: - I have recently switched to GNU Guix but I still use NixOS o my wife’s machine. This is good to know! :smile:

I tried that solution. I got the x11 login windows, I saw plasma starting/loading but then I just got a black screen. I’m using Nixos Unstable.

Any idea why it’s not working anymore?

Figured it out: I first needed to log out on the remove machine before connecting with RDP.