[Nix-dev] packaging windows applications through wine

Badi' Abdul-Wahid abdulwahidc at gmail.com
Tue Apr 25 18:33:55 CEST 2017


My (quasi-nixified) approach is separate the installation from launching
the app. Installation is run via a manually invoked install.sh while
launching is packaged with a nix derivation that I install.

My install.sh looks something like this:

ME="$(cd $(dirname $0) && pwd -P)"
APP=foobarbaz
INSTALLER=install.exe
export WINEPREFIX=$HOME/wineprefix/$APP
cd "$ME"
wine "$INSTALLER"

(I don't have access to my home computer right now so the above is from
memory).

I then define in my config.nix something like:


  run-in-wine =
    { name
    , cpath
    , exe
    , prefix
    , stdenv, bash, wineFull, ...
    }:
    stdenv.mkDerivation {
      name = "run-${name}";
      src = builtins.toFile "run-${name}.sh" ''
        #!/usr/bin/env bash
        cd "${prefix}/drive_c/${cpath}"
        exec wine "${exe}"
      '';
      phases = [ "installPhase" ];
      installPhase = ''
        mkdir -p $out/bin
        cp $src $out/bin/run-${name}
        chmod +x $out/bin/run-${name}
      '';
      buildInputs = [];
      propagatedBuildInputs = [ wineFull ];
    };


  run-foobarbaz = callPackage run-in-wine {
    prefix = "~/wineprefix";
    name = "foobarbaz";
    cpath = "relative/to/${prefix}/drive_c";
    exe = "run_foobarbaz.exe";
  };


With the run-foobarbaz derivation installed I can invoke run-foobarbaz from
rofi, dmenu, or the CLI.


Incidentally, I've found that I need to use "nouveau" instead of "nvidia"
for services.xserver.videoDrivers for my nvidia graphics card else the
(successfully installed) app would not launch. There may be another fix,
but I stopped digging once I switched to nouveau.



On Mon, Apr 24, 2017 at 8:01 PM, aszlig <aszlig at redmoonstudios.org> wrote:

> On Mon, Apr 24, 2017 at 02:39:02AM +0000, Taeer Bar-Yam wrote:
> > When one installs things through wine, one usually has to click
> > through a bunch of agreements for things installed via winetricks. Can
> > we bypass this so we can make nix packages for these things that
> > installs nicely?
>
> That really depnds on the installer:
>
>   * If it's an MSI file, you may be able to automate this using msiexec.
>   * Some installers can be extracted via cabextract, unshield, 7zip, etc...
>   * You could override specific functionality via WINEDLLOVERRIDES, but
>     that might be a bit difficult in a GUI application.
>   * Automate it via something like xdotool in an Xvfb.
>
> I guess the simplest method would be the latter, because if you extract
> the installer archive there might be some missing files or registry keys
> that you need to apply as well.
>
> Here is an example for automating this via xdotool:
>
> https://github.com/openlab-aux/vuizvui/blob/97e440e996e9c418
> e46af3dbcdba58595b5c11ea/pkgs/aszlig/santander/default.nix#L63-L74
>
> In this case the installer is quite simple because all you need to do is
> click "Next -> Next -> Next -> ..." here.
>
> If it's something more complicated, like if you need ta accept an EULA,
> then you might be either in luck and you just need to apply something
> like "key alt+a Return" all over again if for example alt+a is for
> "accept EULA".
>
> In most cases however it isn't that easy, so I'd try to look whether you
> can get information about what's displayed via tracing the font
> rendering calls in wine. Another way would be to use OCR, but that is
> slower and might be a bit error prone.
>
> > The other challenge I see is where do you put the wineprefix? Because
> > on the one hand you want the installation to happen at system build
> > time, so that would suggest the nix store. But you also want the
> > application to be able to write files (like saves &c) so that would
> > have to be in your home folder.
>
> You could set the user data directory to some other unix path via
> dosdevices/ and change %APPDATA% accordingly, like:
>
> https://support.microsoft.com/en-us/help/190234/prb-how-to-m
> odify-the-personal-directory-for-all-new-users
>
> Another way would be to use a wrapper that uses overlayfs to write all
> the differences of the immutable store path to some location within the
> home directory (like eg. ${XDG_DATA_HOME:-$HOME/.local/share}/your_app).
>
> > Is how to package wine applications a solved problem, or do I need to
> > do some creative work?
>
> The latter :-)
>
> a!
> --
> aszlig
> Universal dilettante
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iF4EAREIAAYFAlj+kccACgkQ0OvQ7IwtyWEIugEAjWghnvvaFOh6MSs3qAK3EOoI
> g8rIjX230t7flmL4ahwA/RBckrZw2L1arsugUpMldg6GJSDlWpMEjAuHTgb0RlX5
> =Hhom
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>
>


-- 

Badi' Abdul-Wahid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170425/e1ed392a/attachment-0001.html>


More information about the nix-dev mailing list