|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchFromGitHub, |
| 5 | + cmake, |
| 6 | + makeWrapper, |
| 7 | + flac, |
| 8 | + libmpeg2, |
| 9 | + libmpg123, |
| 10 | + libpng, |
| 11 | + libserialport, |
| 12 | + portmidi, |
| 13 | + SDL2, |
| 14 | + SDL2_image, |
| 15 | + SDL2_ttf, |
| 16 | +}: |
| 17 | + |
| 18 | +stdenv.mkDerivation (finalAttrs: { |
| 19 | + pname = "amiberry"; |
| 20 | + version = "5.7.4"; |
| 21 | + |
| 22 | + src = fetchFromGitHub { |
| 23 | + owner = "BlitterStudio"; |
| 24 | + repo = "amiberry"; |
| 25 | + rev = "refs/tags/v${finalAttrs.version}"; |
| 26 | + hash = "sha256-EOoVJYefX2pQ2Zz9bLD1RS47u/+7ZWTMwZYha0juF64="; |
| 27 | + }; |
| 28 | + |
| 29 | + nativeBuildInputs = [ |
| 30 | + cmake |
| 31 | + makeWrapper |
| 32 | + ]; |
| 33 | + |
| 34 | + buildInputs = [ |
| 35 | + flac |
| 36 | + libmpeg2 |
| 37 | + libmpg123 |
| 38 | + libpng |
| 39 | + libserialport |
| 40 | + portmidi |
| 41 | + SDL2 |
| 42 | + SDL2_image |
| 43 | + SDL2_ttf |
| 44 | + ]; |
| 45 | + |
| 46 | + enableParallelBuilding = true; |
| 47 | + |
| 48 | + # Amiberry has traditionally behaved as a "Portable" app, meaning that it was designed to expect everything |
| 49 | + # under the same directory. This is not compatible with Nix package conventions. |
| 50 | + # The Amiberry behavior has changed since versions 5.7.4 and 6.3.4 (see |
| 51 | + # https://github.com/BlitterStudio/amiberry/wiki/FAQ#q-where-does-amiberry-look-for-its-files-can-i-change-that |
| 52 | + # for more information), however this is still not compatible with Nix packaging. The AMIBERRY_DATA_DIR can go |
| 53 | + # in the nix store but the Amiberry configuration files must be stored in a user writable location. |
| 54 | + # Fortunately Amiberry provides environment variables for specifying these locations which we can supply with the |
| 55 | + # wrapper script below. |
| 56 | + # One more caveat: Amiberry expects the configuration files path (AMIBERRY_HOME_DIR) to exist, otherwise it will |
| 57 | + # fall back to behaving like a "Portable" app. The wrapper below ensures that the AMIBERRY_HOME_DIR path exists, |
| 58 | + # preventing that fallback. |
| 59 | + installPhase = '' |
| 60 | + runHook preInstall |
| 61 | + mkdir -p $out/bin |
| 62 | + cp amiberry $out/bin/ |
| 63 | + cp -r abr data $out/ |
| 64 | + wrapProgram $out/bin/amiberry \ |
| 65 | + --set-default AMIBERRY_DATA_DIR $out \ |
| 66 | + --run 'AMIBERRY_HOME_DIR="$HOME/.amiberry"' \ |
| 67 | + --run 'mkdir -p \ |
| 68 | + $AMIBERRY_HOME_DIR/kickstarts \ |
| 69 | + $AMIBERRY_HOME_DIR/conf \ |
| 70 | + $AMIBERRY_HOME_DIR/nvram \ |
| 71 | + $AMIBERRY_HOME_DIR/plugins \ |
| 72 | + $AMIBERRY_HOME_DIR/screenshots \ |
| 73 | + $AMIBERRY_HOME_DIR/savestates \ |
| 74 | + $AMIBERRY_HOME_DIR/controllers \ |
| 75 | + $AMIBERRY_HOME_DIR/whdboot \ |
| 76 | + $AMIBERRY_HOME_DIR/lha \ |
| 77 | + $AMIBERRY_HOME_DIR/floppies \ |
| 78 | + $AMIBERRY_HOME_DIR/cdroms \ |
| 79 | + $AMIBERRY_HOME_DIR/harddrives' |
| 80 | + runHook postInstall |
| 81 | + ''; |
| 82 | + |
| 83 | + meta = with lib; { |
| 84 | + homepage = "https://github.com/BlitterStudio/amiberry"; |
| 85 | + description = "Optimized Amiga emulator for Linux/macOS"; |
| 86 | + license = licenses.gpl3; |
| 87 | + platforms = platforms.linux; |
| 88 | + maintainers = with maintainers; [ michaelshmitty ]; |
| 89 | + mainProgram = "amiberry"; |
| 90 | + }; |
| 91 | +}) |
0 commit comments