Running GUI app inside LXC Container

I would like to run several GUI apps inside a variety (openSUSE and Ubuntu) of LXC containers.

I googled this and tried following several non-nixos specific guides without success. Is anyone aware of nixos based guides on how to do this, or able to share how this is done?

I’m running latest nixos 22.11 with Gnome.

1 Like

I think the most important bit is to make X11 and/or Wayland sockets of the host available in the container. That is mounting the actual socket in the container filesystem and setting the ENV variable in the container accordingly.

Is is described here for nixos containers here Application Isolation using NixOS Containers · Marcin Sucharski

Hope that helps a bit.

1 Like

its tough with docker, it’s tough with any type of container.

@matthewcroughan , had done a lot around this area… it’s possible but it’s hacky.

can i ask what your use case is? i’m also interested on the how and why programmers are using containers.

Thank you for the reply and the link. It more comprehensively highlights the things to attend to.

I will try to apply these details in my situation and provide an update.

I want to access certain applications that aren’t officially supported on nixos to support development activities.

I have tried setting up the applications on nixos and been unsuccessful resolving the issues that arose.

As an example, TWS from IBKR doesn’t install and run. It complains about the architecture when trying to install the Java that is bundled with the install and doesn’t work if I install Java myself on nixos.

Also, I would prefer to run the self updating version of the application if possible which defeats the declarative benefits of nixos. As such, it seems that if I can host the app in a container that matches the Linux flavour preferred by the app, then I may be able to derive all the benefits of nixos on the host while still be able to access a collection of applications staged in Linux environments that more closely match production.

Other than that, it seems like it would be a neat thing to do :slight_smile:

Thx

I usually put podman and and distrobox to work for that use case, not only on NixOS, but also e.g. to run yocto builds in a LTS-Ubuntu while being on the latest Ubuntu (with podman/distrobox provided by a Nix-devshell).

Thanks, I’ve never used those before and will look at that option as well.

sounds like you fighting a few battles there!!

Well I got it working really well but now I’m ironing out refinements.

Once, I’m done I’ll post the recipe.

2 Likes

Were you able to get a recipe finished?

Yes with varying degrees of success. I was able to get a java based trading solution to work fine but unable to get a javascript solution working. I’ll review what I did for the java solution and post it if you are interested.

1 Like