about summary refs log tree commit diff
path: root/pkgs/by-name/bl/blastem/package.nix
blob: 6cc7e97c7c8b15721fa7a413009f7969ffe8705a (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
{
  lib,
  stdenv,
  fetchhg,
  pkg-config,
  makeBinaryWrapper,
  SDL2,
  glew,
  gtk3,
  testers,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "blastem";
  version = "0.6.2-unstable-2024-03-31";

  src = fetchhg {
    url = "https://www.retrodev.com/repos/blastem";
    rev = "48ab1e3e5df5";
    hash = "sha256-UZl5fIE7LJqxwS8kFJ3xr8BJyHF60dnRNeA5k7lAuxg=";
  };

  # will probably be fixed in https://github.com/NixOS/nixpkgs/pull/302481
  postPatch = lib.optionalString stdenv.isDarwin ''
    substituteInPlace Makefile \
        --replace-fail "-flto" ""
  '';

  nativeBuildInputs = [
    pkg-config
    makeBinaryWrapper
  ];

  buildInputs = [
    gtk3
    SDL2
    glew
  ];

  # Note: menu.bin cannot be generated yet, because it would
  # need the `vasmm68k_mot` executable (part of vbcc for amigaos68k
  # Luckily, menu.bin doesn't need to be present for the emulator to function

  makeFlags = [ "HOST_ZLIB=1" ];

  env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL2}/include/SDL2";

  installPhase = ''
    runHook preInstall

    # not sure if any executable other than blastem is really needed here
    install -Dm755 blastem dis zdis termhelper -t $out/share/blastem
    install -Dm644 gamecontrollerdb.txt default.cfg rom.db -t $out/share/blastem
    cp -r shaders $out/share/blastem/shaders

    # wrapping instead of sym-linking makes sure argv0 stays at the original location
    makeWrapper $out/share/blastem/blastem $out/bin/blastem

    runHook postInstall
  '';

  passthru.tests.version = testers.testVersion {
    package = finalAttrs.finalPackage;
    command = "blastem -v";
    version = "0.6.3-pre"; # remove line when moving to a stable version
  };

  meta = {
    description = "The fast and accurate Genesis emulator";
    homepage = "https://www.retrodev.com/blastem/";
    license = lib.licenses.gpl3Plus;
    mainProgram = "blastem";
    maintainers = with lib.maintainers; [ tomasajt ];
    platforms = [
      "i686-linux"
      "x86_64-linux"
      "x86_64-darwin"
    ];
  };
})