summaryrefslogtreecommitdiff
path: root/pkgs/by-name/do/dolphin-emu/package.nix
blob: c22d4afd73d5e25adea5970109b7868a38bb34c1 (about) (plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
  lib,
  stdenv,
  fetchFromGitHub,

  # nativeBuildInputs
  cmake,
  pkg-config,
  qt6,
  # darwin-only
  xcbuild,

  # buildInputs
  bzip2,
  cubeb,
  curl,
  enet,
  ffmpeg,
  fmt_10,
  gtest,
  hidapi,
  libXdmcp,
  libpulseaudio,
  libspng,
  libusb1,
  lz4,
  lzo,
  mbedtls_2,
  miniupnpc,
  minizip-ng,
  openal,
  pugixml,
  SDL2,
  sfml,
  xxHash,
  xz,
  # linux-only
  alsa-lib,
  bluez,
  libGL,
  libXext,
  libXrandr,
  libevdev,
  udev,
  vulkan-loader,
  # darwin-only
  moltenvk,

  # passthru
  testers,
  nix-update-script,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "dolphin-emu";
  version = "2503";

  src = fetchFromGitHub {
    owner = "dolphin-emu";
    repo = "dolphin";
    tag = finalAttrs.version;
    fetchSubmodules = true;
    hash = "sha256-oqJKXFcsFgoYjUqdk3Z/CIFhOa8w0drcF4JwtHRI1Hs=";
  };

  strictDeps = true;

  nativeBuildInputs =
    [
      cmake
      pkg-config
      qt6.wrapQtAppsHook
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      xcbuild # for plutil
    ];

  buildInputs =
    [
      bzip2
      cubeb
      curl
      enet
      ffmpeg
      fmt_10
      gtest
      hidapi
      libXdmcp
      libpulseaudio
      libspng
      libusb1
      lz4
      lzo
      mbedtls_2
      miniupnpc
      minizip-ng
      openal
      pugixml
      qt6.qtbase
      qt6.qtsvg
      SDL2
      sfml
      xxHash
      xz
      # Causes linker errors with minizip-ng, prefer vendored. Possible reason why: https://github.com/dolphin-emu/dolphin/pull/12070#issuecomment-1677311838
      #zlib-ng
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      alsa-lib
      bluez
      libGL
      libXext
      libXrandr
      libevdev
      # FIXME: Vendored version is newer than mgba's stable release, remove the comment on next mgba's version
      #mgba # Derivation doesn't support Darwin
      udev
      vulkan-loader
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      moltenvk
    ];

  cmakeFlags =
    [
      (lib.cmakeFeature "DISTRIBUTOR" "NixOS")
      (lib.cmakeFeature "DOLPHIN_WC_REVISION" finalAttrs.src.rev)
      (lib.cmakeFeature "DOLPHIN_WC_DESCRIBE" finalAttrs.version)
      (lib.cmakeFeature "DOLPHIN_WC_BRANCH" "master")
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      (lib.cmakeBool "OSX_USE_DEFAULT_SEARCH_PATH" true)
      (lib.cmakeBool "USE_BUNDLED_MOLTENVK" false)
      (lib.cmakeBool "MACOS_CODE_SIGNING" false)
      # Bundles the application folder into a standalone executable, so we cannot devendor libraries
      (lib.cmakeBool "SKIP_POSTPROCESS_BUNDLE" true)
      # Needs xcode so compilation fails with it enabled. We would want the version to be fixed anyways.
      # Note: The updater isn't available on linux, so we don't need to disable it there.
      (lib.cmakeBool "ENABLE_AUTOUPDATE" false)
    ];

  qtWrapperArgs = lib.optionals stdenv.hostPlatform.isLinux [
    "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]}"
    # https://bugs.dolphin-emu.org/issues/11807
    # The .desktop file should already set this, but Dolphin may be launched in other ways
    "--set QT_QPA_PLATFORM xcb"
  ];

  postInstall =
    lib.optionalString stdenv.hostPlatform.isLinux ''
      install -D $src/Data/51-usb-device.rules $out/etc/udev/rules.d/51-usb-device.rules
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      # Only gets installed automatically if the standalone executable is used
      mkdir -p $out/Applications
      cp -r ./Binaries/Dolphin.app $out/Applications
      ln -s $out/Applications/Dolphin.app/Contents/MacOS/Dolphin $out/bin
    '';

  passthru = {
    tests = {
      version = testers.testVersion {
        package = finalAttrs.finalPackage;
        command = "dolphin-emu-nogui --version";
        inherit (finalAttrs) version;
      };
    };
    updateScript = nix-update-script {
      extraArgs = [
        "--version-regex"
        "([0-9]+)"
      ];
    };
  };

  meta = {
    homepage = "https://dolphin-emu.org";
    description = "Gamecube/Wii/Triforce emulator for x86_64 and ARMv8";
    mainProgram = if stdenv.hostPlatform.isDarwin then "Dolphin" else "dolphin-emu";
    branch = "master";
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.unix;
    badPlatforms = [
      # error: implicit instantiation of undefined template 'std::char_traits<unsigned int>'
      lib.systems.inspect.patterns.isDarwin
    ];
    maintainers = with lib.maintainers; [ pbsds ];
  };
})