Using wine? (Installing Foobar2000)

I wanted to install Foobar2000 on NixOS. However, it will require Wine. But I couldn’t find how to use Wine on NixOS.

Is there a way to package windows applications as if they were native using Wine and Nix?

Some people do this, here’s a discourse thread discussing some options that I keep meaning to read again: What is your approach to packaging Wine applications with Nix derivations?

One day I’ll package all my GoG games :wink:

It’s definitely not necessary, though, you can just use wine with a normal prefix.

Here’s an example package using mkWindowsApp, which you can get from my erosanix flake:

The app crashes with an NTLM error, so additional work would be needed, but this gives you the idea.

{ stdenv
, lib
, mkWindowsApp
, wine
, fetchurl
, makeDesktopItem
, makeDesktopIcon
, copyDesktopItems
, copyDesktopIcons
}:
mkWindowsApp rec {
  inherit wine;

  pname = "foobar2000";
  version = "1.6.10";
  wineArch = "win64";

  src = fetchurl {
    url = "https://www.foobar2000.org/files/foobar2000_v${version}.exe";
    sha256 = "02yk82gzddl8rcmr4i5p3nvdcz08c6qkdmk8a1fl4j4yd4piriyk";
  };

  dontUnpack = true;
  nativeBuildInputs = [ copyDesktopItems copyDesktopIcons ];

  winAppInstall = ''
    wine start /unix ${src} /S
  '';

  winAppRun = ''
    wine start /unix "$WINEPREFIX/drive_c/Program Files (x86)/foobar2000/foobar2000.exe"
  '';

  installPhase = ''
    runHook preInstall

    ln -s $out/bin/.launcher $out/bin/${pname}

    runHook postInstall
  '';

  desktopItems = [
    (makeDesktopItem {
      name = pname;
      exec = pname;
      icon = pname;
      desktopName = "Foobar2000";
      categories = ["Audio" "Player"];
    })
  ];

  desktopIcon = makeDesktopIcon {
    name = "foobar2000";

    src = fetchurl {
      url = "https://www.foobar2000.org/favicon.ico";
      sha256 = "1lk997iqaf7ma7jrfld6wc6spcgmz198nhrqclxn7bjvdws4csr6";
    };
  };

  meta = with lib; {
    description = "An advanced freeware audio player for the Windows platform.";
    homepage = "https://www.foobar2000.org";
    license = licenses.unfree;
    platforms = [ "x86_64-linux" ];
   };
}
4 Likes

I got it working :slight_smile:

The package is here.

You can demo it with nix run github:emmanuelrosa/erosanix#foobar2000

3 Likes

Amazing! Thank you so much for sharing this! :smiley: