about summary refs log tree commit diff
path: root/pkgs/by-name/xe/xemu/package.nix
blob: b1205af44133636f0b7b441a94443623f1b2ade0 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
{
  lib,
  SDL2,
  SDL2_image,
  fetchFromGitHub,
  gettext,
  glib,
  gtk3,
  libGLU,
  libdrm,
  libepoxy,
  libpcap,
  libsamplerate,
  libslirp,
  mesa,
  meson,
  ninja,
  openssl,
  perl,
  pkg-config,
  python3Packages,
  stdenv,
  vte,
  which,
  wrapGAppsHook3,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "xemu";
  version = "0.7.127";

  src = fetchFromGitHub {
    owner = "xemu-project";
    repo = "xemu";
    rev = "v${finalAttrs.version}";
    fetchSubmodules = true;
    hash = "sha256-qf4zc+qZSLZLjqpKUVgSEhb5VGAzkiRlJSsSCCbNImU=";
  };

  nativeBuildInputs =
    [
      SDL2
      meson
      ninja
      perl
      pkg-config
      which
      wrapGAppsHook3
    ]
    ++ (with python3Packages; [
      python
      pyyaml
    ]);

  buildInputs = [
    SDL2
    SDL2_image
    gettext
    glib
    gtk3
    libGLU
    libdrm
    libepoxy
    libpcap
    libsamplerate
    libslirp
    mesa
    openssl
    vte
  ];

  configureFlags = [
    "--disable-strip"
    "--meson=meson"
    "--target-list=i386-softmmu"
    "--disable-werror"
  ];

  buildFlags = [ "qemu-system-i386" ];

  separateDebugInfo = true;

  dontUseMesonConfigure = true;

  setOutputFlags = false;

  strictDeps = true;

  postPatch = ''
    patchShebangs .
    substituteInPlace ./scripts/xemu-version.sh \
      --replace 'date -u' "date -d @$SOURCE_DATE_EPOCH '+%Y-%m-%d %H:%M:%S'"
  '';

  preConfigure =
    ''
      configureFlagsArray+=("--extra-cflags=-DXBOX=1 -Wno-error=redundant-decls")
    ''
    +
      # When the data below can't be obtained through git, the build process tries
      # to run `XEMU_COMMIT=$(cat XEMU_COMMIT)` (and similar)
      ''
        echo '${finalAttrs.version}' > XEMU_VERSION
      '';

  preBuild = ''
    cd build
    substituteInPlace ./build.ninja --replace /usr/bin/env $(which env)
  '';

  installPhase =
    let
      installIcon = resolution: ''
        install -Dm644 -T ../ui/icons/xemu_${resolution}.png \
          $out/share/icons/hicolor/${resolution}/apps/xemu.png
      '';
    in
    ''
      runHook preInstall

      install -Dm755 -T qemu-system-i386 $out/bin/xemu
    ''
    + (lib.concatMapStringsSep "\n" installIcon [
      "16x16"
      "24x24"
      "32x32"
      "48x48"
      "128x128"
      "256x256"
      "512x512"
    ])
    + "\n"
    + ''
      install -Dm644 -T ../ui/xemu.desktop $out/share/applications/xemu.desktop

      runHook postInstall
    '';

  meta = {
    homepage = "https://xemu.app/";
    description = "Original Xbox emulator";
    longDescription = ''
      A free and open-source application that emulates the original Microsoft
      Xbox game console, enabling people to play their original Xbox games on
      Windows, macOS, and Linux systems.
    '';
    changelog = "https://github.com/xemu-project/xemu/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.gpl2Plus;
    mainProgram = "xemu";
    maintainers = with lib.maintainers; [ AndersonTorres ];
    platforms = lib.platforms.linux;
  };
})
# TODO: investigate failure when using __structuredAttrs