about summary refs log tree commit diff
path: root/nixpkgs/pkgs/games/bugdom/default.nix
blob: 01db213de985e3a713aee34e46d57db0495c4787 (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
{ lib, stdenv, fetchFromGitHub, SDL2, IOKit, Foundation, cmake, makeWrapper }:

stdenv.mkDerivation rec {
  pname = "bugdom";
  version = "1.3.3";

  src = fetchFromGitHub {
    owner = "jorio";
    repo = pname;
    rev = version;
    hash = "sha256-oe7xxvoL82YF+EoIJDK6AfN3PmpqeGRlIsbaGx8xGeM=";
    fetchSubmodules = true;
  };

  postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
    # Expects SDL2.framework in specific location, which we don't have
    # Passing this in cmakeFlags doesn't work because the path is hard-coded for Darwin
    substituteInPlace cmake/FindSDL2.cmake \
      --replace 'set(SDL2_LIBRARIES' 'set(SDL2_LIBRARIES "${SDL2}/lib/libSDL2.dylib") #'
    # Expects plutil, which we don't have
    sed -i '/plutil/d' CMakeLists.txt
  '';

  buildInputs = [
    SDL2
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
    IOKit
    Foundation
  ];

  nativeBuildInputs = [
    cmake
    makeWrapper
  ];

  cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [
    "-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}"
    # Expects SDL2.framework in specific location, which we don't have
    "-DSDL2_INCLUDE_DIRS=${SDL2.dev}/include/SDL2"
  ];

  installPhase = ''
    runHook preInstall

  '' + (if stdenv.hostPlatform.isDarwin then ''
    mkdir -p $out/{bin,Applications}
    mv {,$out/Applications/}Bugdom.app
    makeWrapper $out/{Applications/Bugdom.app/Contents/MacOS,bin}/Bugdom
  '' else ''
    mkdir -p $out/share/bugdom
    mv Data $out/share/bugdom
    install -Dm755 {.,$out/bin}/Bugdom
    wrapProgram $out/bin/Bugdom --run "cd $out/share/bugdom"
    install -Dm644 $src/packaging/bugdom.desktop $out/share/applications/bugdom.desktop
    install -Dm644 $src/packaging/bugdom-desktopicon.png $out/share/pixmaps/bugdom-desktopicon.png
  '') + ''

    runHook postInstall
  '';

  meta = with lib; {
    description = "A port of Bugdom, a 1999 Macintosh game by Pangea Software, for modern operating systems";
    homepage = "https://github.com/jorio/Bugdom";
    license = with licenses; [ cc-by-sa-40 ];
    maintainers = with maintainers; [ lux ];
    mainProgram = "Bugdom";
    platforms = platforms.unix;
  };
}