nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 extra-cmake-modules,
8 pkg-config,
9 makeWrapper,
10 freetype,
11 SDL2,
12 glib,
13 pcre2,
14 openal,
15 rtmidi,
16 fluidsynth,
17 jack2,
18 alsa-lib,
19 qt5,
20 libvncserver,
21 discord-gamesdk,
22 libpcap,
23 libslirp,
24 wayland,
25 wayland-scanner,
26 libsndfile,
27 flac,
28 libogg,
29 libvorbis,
30 libopus,
31 libmpg123,
32 libgcrypt,
33
34 enableDynarec ? with stdenv.hostPlatform; isx86 || isAarch,
35 enableNewDynarec ? enableDynarec && stdenv.hostPlatform.isAarch,
36 enableVncRenderer ? false,
37 enableWayland ? stdenv.hostPlatform.isLinux,
38 unfreeEnableDiscord ? false,
39 unfreeEnableRoms ? false,
40}:
41
42stdenv.mkDerivation (finalAttrs: {
43 pname = "86Box";
44 version = "5.3";
45
46 src = fetchFromGitHub {
47 owner = "86Box";
48 repo = "86Box";
49 tag = "v${finalAttrs.version}";
50 hash = "sha256-n68Ghhsv15TzpOMH4dBTNxa6AYwqN5s2C5pyO9VVaco=";
51 };
52
53 patches = [
54 ./darwin.patch
55 # Fix build: Only make the fallthrough define available in C code
56 # https://github.com/86Box/86Box/issues/6607
57 (fetchpatch {
58 name = "fix-fallthrough-define-c-only.patch";
59 url = "https://github.com/86Box/86Box/commit/0092ce15de3efac108b961882f870a8c05e8c38f.patch";
60 hash = "sha256-DqjOtnyk6Zv9XHCLeuxD1wcLfvjGwGFvUWS0alXcchs=";
61 })
62 ];
63
64 postPatch = ''
65 substituteAllInPlace src/qt/qt_platform.cpp
66 '';
67
68 nativeBuildInputs = [
69 cmake
70 pkg-config
71 makeWrapper
72 qt5.wrapQtAppsHook
73 ]
74 ++ lib.optionals enableWayland [
75 extra-cmake-modules
76 wayland-scanner
77 ];
78
79 buildInputs = [
80 freetype
81 fluidsynth
82 SDL2
83 glib
84 openal
85 rtmidi
86 pcre2
87 jack2
88 libpcap
89 libslirp
90 qt5.qtbase
91 qt5.qttools
92 libsndfile
93 flac.dev
94 libogg.dev
95 libvorbis.dev
96 libopus.dev
97 libmpg123.dev
98 ]
99 ++ lib.optional stdenv.hostPlatform.isLinux alsa-lib
100 ++ lib.optional enableWayland wayland
101 ++ lib.optionals enableVncRenderer [
102 libvncserver
103 libgcrypt
104 ];
105
106 cmakeFlags =
107 lib.optional stdenv.hostPlatform.isDarwin "-DCMAKE_MACOSX_BUNDLE=OFF"
108 ++ lib.optional enableNewDynarec "-DNEW_DYNAREC=ON"
109 ++ lib.optional enableVncRenderer "-DVNC=ON"
110 ++ lib.optional (!enableDynarec) "-DDYNAREC=OFF"
111 ++ lib.optional (!unfreeEnableDiscord) "-DDISCORD=OFF";
112
113 postInstall =
114 lib.optionalString stdenv.hostPlatform.isLinux ''
115 install -Dm644 -t $out/share/applications $src/src/unix/assets/net.86box.86Box.desktop
116
117 for size in 48 64 72 96 128 192 256 512; do
118 install -Dm644 -t $out/share/icons/hicolor/"$size"x"$size"/apps \
119 $src/src/unix/assets/"$size"x"$size"/net.86box.86Box.png
120 done;
121 ''
122 + lib.optionalString unfreeEnableRoms ''
123 mkdir -p $out/share/86Box
124 ln -s ${finalAttrs.passthru.roms} $out/share/86Box/roms
125 '';
126
127 passthru = {
128 roms = fetchFromGitHub {
129 owner = "86Box";
130 repo = "roms";
131 tag = "v${finalAttrs.version}";
132 hash = "sha256-7/xhhT29ijGNVlW7oJXdyJuhUwVs0b4dIUjc3lVtNEY=";
133 };
134 updateScript = ./update.sh;
135 };
136
137 # Some libraries are loaded dynamically, but QLibrary doesn't seem to search
138 # the runpath, so use a wrapper instead.
139 preFixup =
140 let
141 libPath = lib.makeLibraryPath ([ libpcap ] ++ lib.optional unfreeEnableDiscord discord-gamesdk);
142 libPathVar = if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
143 in
144 ''
145 makeWrapperArgs+=(--prefix ${libPathVar} : "${libPath}")
146 '';
147
148 meta = {
149 description = "Emulator of x86-based machines based on PCem";
150 mainProgram = "86Box";
151 homepage = "https://86box.net/";
152 changelog = "https://github.com/86Box/86Box/releases/tag/v${finalAttrs.version}";
153 license =
154 with lib.licenses;
155 [ gpl2Only ] ++ lib.optional (unfreeEnableDiscord || unfreeEnableRoms) unfree;
156 maintainers = with lib.maintainers; [
157 jchw
158 matteopacini
159 ];
160 platforms = lib.platforms.linux ++ lib.platforms.darwin;
161 };
162})