1 import ./make-test-python.nix ({ pkgs, ...} : {
2 # How to interactively test this module if the audio actually works
4 # - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive
5 # - test_script() # launches the terminal and the tests itself
6 # - server.send_monitor_command("hostfwd_add tcp::3389-:3389") # forward the RDP port to the host
7 # - Connect with the RDP client you like (ex: Remmina)
8 # - Don't forget to enable audio support. In remmina: Advanced -> Audio output mode to Local (default is Off)
9 # - Open a browser or something that plays sound. Ex: chromium
11 name = "xrdp-with-audio-pulseaudio";
12 meta = with pkgs.lib.maintainers; {
13 maintainers = [ lucasew ];
17 server = { pkgs, ... }: {
18 imports = [ ./common/user-account.nix ];
20 environment.etc."xrdp/test.txt".text = "Shouldn't conflict";
22 services.xrdp.enable = true;
23 services.xrdp.audio.enable = true;
24 services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
26 hardware.pulseaudio = {
30 systemd.user.services.pactl-list = {
32 while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do
36 ${pkgs.pulseaudio}/bin/pactl list
38 ${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source
40 ${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink
43 wantedBy = [ "default.target" ];
46 networking.firewall.allowedTCPPorts = [ 3389 ];
49 client = { pkgs, ... }: {
50 imports = [ ./common/x11.nix ./common/user-account.nix ];
51 test-support.displayManager.auto.user = "alice";
53 environment.systemPackages = [ pkgs.freerdp ];
55 services.xrdp.enable = true;
56 services.xrdp.audio.enable = true;
57 services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
59 hardware.pulseaudio = {
65 testScript = { nodes, ... }: let
66 user = nodes.client.config.users.users.alice;
71 client.wait_for_file("${user.home}/.Xauthority")
72 client.succeed("xauth merge ${user.home}/.Xauthority")
76 client.execute("xterm >&2 &")
79 client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password} /sound\n")
83 client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket
85 client.screenshot("localrdp")
87 client.execute("xterm >&2 &")
89 client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n")
92 server.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket
93 server.succeed('[ "$(cat /tmp/pulseaudio-source)" == "xrdp-source" ]')
94 server.succeed('[ "$(cat /tmp/pulseaudio-sink)" == "xrdp-sink" ]')
95 client.screenshot("remoterdp")