summary refs log tree commit diff
path: root/pkgs/misc/emulators/wine/base.nix
blob: 60fb8e11391b8cc8be230282bc12ec407f694229 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ stdenv, lib, pkgArches,
  name, version, src, monos, geckos, platforms,
  pkgconfig, fontforge, makeWrapper, flex, bison,
  pulseaudioSupport,
  buildScript ? null, configureFlags ? ""
}:

assert stdenv.isLinux;
assert stdenv.cc.cc.isGNU or false;

with import ./util.nix { inherit lib; };

stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) {
  builder = buildScript;
}) // rec {
  inherit name src configureFlags;

  nativeBuildInputs = [
    pkgconfig fontforge makeWrapper flex bison
  ];

  buildInputs = toBuildInputs pkgArches (pkgs: (with pkgs; [
    freetype fontconfig mesa mesa_noglu.osmesa libdrm libpng libjpeg openssl gnutls cups ncurses
    alsaLib libxml2 libxslt lcms2 gettext dbus mpg123 openal
  ])
  ++ lib.optional pulseaudioSupport pkgs.libpulseaudio
  ++ (with pkgs.xorg; [
    libXi libXcursor libXinerama libXrandr libXrender libXxf86vm libXcomposite libXext
  ]));

  # Wine locates a lot of libraries dynamically through dlopen().  Add
  # them to the RPATH so that the user doesn't have to set them in
  # LD_LIBRARY_PATH.
  NIX_LDFLAGS = map (path: "-rpath " + path) (
      map (x: "${x}/lib") ([ stdenv.cc.cc ] ++ (map (x: x.lib or x.out) buildInputs))
      # libpulsecommon.so is linked but not found otherwise
      ++ lib.optionals pulseaudioSupport (map (x: "${x.lib or x.out}/lib/pulseaudio") (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
    );

  # Don't shrink the ELF RPATHs in order to keep the extra RPATH
  # elements specified above.
  dontPatchELF = true;

  # Disable stripping to avoid breaking placeholder DLLs/EXEs.
  # Symptoms of broken placeholders are: when the wineprefix is created
  # drive_c/windows/system32 will only contain a few files instead of
  # hundreds, there will be an error about winemenubuilder and MountMgr
  # on startup of Wine, and the Drives tab in winecfg will show an error.
  dontStrip = true;

  ## FIXME
  # Add capability to ignore known failing tests
  # and enable doCheck
  doCheck = false;
  
  postInstall = let
    links = prefix: pkg: "ln -s ${pkg} $out/${prefix}/${pkg.name}";
  in ''
    mkdir -p $out/share/wine/gecko $out/share/wine/mono/
    ${lib.strings.concatStringsSep "\n"
          ((map (links "share/wine/gecko") geckos)
        ++ (map (links "share/wine/mono")  monos))}
  '';
  
  enableParallelBuilding = true;

  passthru = { inherit pkgArches; };
  meta = {
    inherit version platforms;
    homepage = "http://www.winehq.org/";
    license = "LGPL";
    description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
    maintainers = [stdenv.lib.maintainers.raskin];
  };
})