tuicam: init at 0.0.2 (#377825)
[NixPkgs.git] / pkgs / by-name / hi / higan / package.nix
blob59558b72e00c2cff1b3a5b3373dd6c5a965d94a9
2   lib,
3   SDL2,
4   alsa-lib,
5   fetchFromGitHub,
6   gtk3,
7   gtksourceview3,
8   libGL,
9   libGLU,
10   libX11,
11   libXv,
12   libao,
13   libicns,
14   libpulseaudio,
15   openal,
16   installShellFiles,
17   pkg-config,
18   runtimeShell,
19   stdenv,
20   udev,
21   unstableGitUpdater,
24 stdenv.mkDerivation (finalAttrs: {
25   pname = "higan";
26   version = "115-unstable-2024-09-04";
28   src = fetchFromGitHub {
29     owner = "higan-emu";
30     repo = "higan";
31     rev = "a03b2e94c620eb12ab6f9936aee50e4389bee2ff";
32     hash = "sha256-VpwHjA0LufKDnGRAS906Qh3R2pVt4uUGXxsRcca9SyM=";
33   };
35   nativeBuildInputs =
36     [
37       installShellFiles
38       pkg-config
39     ]
40     ++ lib.optionals stdenv.hostPlatform.isDarwin [
41       libicns
42     ];
44   buildInputs =
45     [
46       SDL2
47       libao
48     ]
49     ++ lib.optionals stdenv.hostPlatform.isLinux [
50       alsa-lib
51       gtk3
52       gtksourceview3
53       libGL
54       libGLU
55       libX11
56       libXv
57       libpulseaudio
58       openal
59       udev
60     ];
62   patches = [
63     # Includes cmath header
64     ./patches/0001-include-cmath.patch
65     # Uses png2icns instead of sips
66     ./patches/0002-sips-to-png2icns.patch
67   ];
69   dontConfigure = true;
71   enableParallelBuilding = true;
73   buildPhase =
74     let
75       platform =
76         if stdenv.hostPlatform.isLinux then
77           "linux"
78         else if stdenv.hostPlatform.isDarwin then
79           "macos"
80         else if stdenv.hostPlatform.isBSD then
81           "bsd"
82         else if stdenv.hostPlatform.isWindows then
83           "windows"
84         else
85           throw "Unknown platform for higan: ${stdenv.hostPlatform.system}";
86     in
87     ''
88       runHook preBuild
90       make -C higan-ui -j$NIX_BUILD_CORES \
91         compiler=${stdenv.cc.targetPrefix}c++ \
92         platform=${platform} \
93         openmp=true \
94         hiro=gtk3 \
95         build=accuracy \
96         local=false \
97         cores="cv fc gb gba md ms msx ngp pce sfc sg ws"
99       make -C icarus -j$NIX_BUILD_CORES \
100         compiler=${stdenv.cc.targetPrefix}c++ \
101         platform=${platform} \
102         openmp=true \
103         hiro=gtk3
105       runHook postBuild
106     '';
108   installPhase =
109     ''
110       runHook preInstall
112     ''
113     + (
114       if stdenv.hostPlatform.isDarwin then
115         ''
116           mkdir $out
117           mv higan/out/higan.app $out/
118           mv icarus/out/icarus.app $out/
119         ''
120       else
121         ''
122           installBin higan-ui/out/higan icarus/out/icarus
124           install -d $out/share/applications
125           install higan-ui/resource/higan.desktop -t $out/share/applications/
126           install icarus/resource/icarus.desktop -t $out/share/applications/
128           install -d $out/share/pixmaps
129           install higan/higan/resource/higan.svg $out/share/pixmaps/higan-icon.svg
130           install higan/higan/resource/logo.png $out/share/pixmaps/higan-icon.png
131           install icarus/resource/icarus.svg $out/share/pixmaps/icarus-icon.svg
132           install icarus/resource/icarus.png $out/share/pixmaps/icarus-icon.png
133         ''
134     )
135     + ''
136       install -d $out/share/higan
137       cp -rd extras/ higan/System/ $out/share/higan/
139       install -d $out/share/icarus
140       cp -rd icarus/Database icarus/Firmware $out/share/icarus/
141     ''
142     + (
143       # A dirty workaround, suggested by @cpages:
144       # we create a first-run script to populate
145       # $HOME with all the stuff needed at runtime
146       let
147         dest =
148           if stdenv.hostPlatform.isDarwin then
149             "\\$HOME/Library/Application Support/higan"
150           else
151             "\\$HOME/higan";
152       in
153       ''
154         mkdir -p $out/bin
155         cat <<EOF > $out/bin/higan-init.sh
156         #!${runtimeShell}
158         cp --recursive --update $out/share/higan/System/ "${dest}"/
160         EOF
162         chmod +x $out/bin/higan-init.sh
163       ''
164     )
165     + ''
167       runHook postInstall
168     '';
170   passthru.updateScript = unstableGitUpdater { };
172   meta = {
173     homepage = "https://github.com/higan-emu/higan";
174     description = "Open-source, cycle-accurate multi-system emulator";
175     longDescription = ''
176       higan is a multi-system emulator, originally developed by Near, with an
177       uncompromising focus on accuracy and code readability.
179       It currently emulates the following systems: Famicom, Famicom Disk System,
180       Super Famicom, Super Game Boy, Game Boy, Game Boy Color, Game Boy Advance,
181       Game Boy Player, SG-1000, SC-3000, Master System, Game Gear, Mega Drive,
182       Mega CD, PC Engine, SuperGrafx, MSX, MSX2, ColecoVision, Neo Geo Pocket,
183       Neo Geo Pocket Color, WonderSwan, WonderSwan Color, SwanCrystal, Pocket
184       Challenge V2.
185     '';
186     license = lib.licenses.gpl3Plus;
187     maintainers = with lib.maintainers; [ AndersonTorres ];
188     platforms = lib.platforms.unix;
189     broken = stdenv.hostPlatform.isDarwin;
190   };
192 # TODO: select between Qt and GTK3
193 # TODO: call Darwin hackers to deal with respective problems