Using Xvfb in checkPhase

hey!

can somebody please stop me if this is a bad idea? I’m trying to test an X systray application i’m working on using Xvfb and xdotool.

Is there precedent of that in nixpkgs? It works when I use a nix-shell to run the tests but using nix-build it somehow blocks. I think it might be related to the chroot but I’m a bit lost on how to debug it…
I also added x11vnc to the setup to spy on the process but I somehow can’t connect to the vnc server inside the build process. In a similar vein I could use ffmpeg to record it but how could I get the recording file out of the nixbld process even if the build fails?

can somebody please stop me if this is a bad idea? I’m trying to test an X systray application i’m working on using Xvfb and xdotool.

Is there precedent of that in nixpkgs? It works when I use a nix-shell to run the tests but using nix-build it somehow blocks. I think it might be related to the chroot but I’m a bit lost on how to debug it…
I also added x11vnc to the setup to spy on the process but I somehow can’t connect to the vnc server inside the build process. In a similar vein I could use ffmpeg to record it but how could I get the recording file out of the nixbld process even if the build fails?

The default mode of doing such things seems to be VM tests. Of course, there is start-up overhead.

When I was writing an xdummy package tests, I didn’t need to do anything unexpected. Of course, there is a question of whether there is a tray at all and whether the application in question blocks or forks, but I expect that you have already checked that.

Sandbox should prevent most things you might want to do from working (you could probably use socat to proxy a VNC socket into a unix domain socket and then use socat as root to proxy back by accessing the chroot directory).

FFmpeg recording should be fine if you specify -K flag. After the build fails, the build directory is kept (and made world-readable).

I would look at a few places where this is already done in Nixpkgs:

It should work fine if you have the right dependencies. @jtojnar was just mentioning this kind of thing:

1 Like

Thanks both of you! I got this working and handed in a PR:

i was starting xvfb myself before but the missing piece was the dbus-session-run to get i3 working.