Wine in nix generated docker container

I try to create a docker container from nix with wine.

To create a container with wine installed i use the following nix expression

{ pkgs ? import <nixpkgs> { system = "x86_64-linux"; }

pkgs.dockerTools.buildImage {
    name = "qt-wine";
    tag = "latest";
    contents = with pkgs; [
      wget git

    config = {
      Cmd = [ "${pkgs.bashInteractive}/bin/bash" ];

However I need some advice on how to use wine to install some windows binaries (in my case qt sdk) into my docker environment.

I’ve got the qt installer exe downloaded in my folder but how do i run it in my nix expression so that it gets installed in my docker container?

Any help is greatly appreciated

You can’t trivially run a Windows installer binary inside a Nix derivation and especially not to install it inside a Docker image.

I guess you could build up a WINE prefix from Nix expressions and copy it to a mutable place at runtime? If that wasn’t bad enough, if that installer needs a GUI though, that’s going to become very complex very fast.

Windows is an imperative mess and generally a lost cause. When I built a Docker container for running a Windows app, I built a container that has a sane WINE env and GUI/VNC setup and then used it to manage an imperative WINE prefix where I manually installed the app.

1 Like

That sadly matches my experience. Trying to package anything involving wine often breaks due to the presence of symlinks, as well. I’ve used the “copy at runtime” approach before, but it’ll take some bespoke scripting to make work in a container.

There was a thread about this a long time ago that goes over some approaches: What is your approach to packaging Wine applications with Nix derivations?

Thank you very much for the answers

That is something I tried to do. The installer needs a GUI but I was able to automate it because the qt installer framework can execute scripts. However the resulting WINEPREFIX (although it is in a relative path from my nix expression file) has symlinks to my home folder internally. Since I don’t know wine very well, I don’t know how to prevent it to link to anything outside the WINEPREFIX.

Have you any experience on how to make a wine prefix self contained? Than I could just copy it into my container. It would be no problem if it would still need to be writable because the container is only used by the ci server and it reloads the container every time I rerun the build.

I’ve read this thread before and it seems to have some great ideas on how to use wine applications on a desktop computer. But I don’t know really how to apply this to containers without x-Server (the installer itself has a GUI. Later in the container I will only use cli tools from qt with wine). But since I’m no expert with windows applications (try to avoid it if I can, since, at least to me, it’s so unpredictable) I don’t quit understand why windows applications have to be in a mutable place. Are they modified at runtime?

You are asking on a very Unixy forum, not many here will have much prior experience with this :slight_smile: If it’s not that, then it’s probably just down to software engineering practices on the platform. A fair number of Linux applications will struggle being run from a read-only location, too.

Ok fair point. There won’t be to many people in this forum who will argue for making things less reproducible. :wink:

1 Like

Perhaps you can use Xdummy or Xvfb to set up a dummy X11 server prior to using Wine. That way Wine will feel happy and save in it’s cosy X11 environment, and move along with its business.

1 Like