nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchFromGitHub, SDL2, IOKit, Foundation, cmake, makeWrapper }:
2
3stdenv.mkDerivation rec {
4 pname = "bugdom";
5 version = "1.3.3";
6
7 src = fetchFromGitHub {
8 owner = "jorio";
9 repo = pname;
10 rev = version;
11 hash = "sha256-oe7xxvoL82YF+EoIJDK6AfN3PmpqeGRlIsbaGx8xGeM=";
12 fetchSubmodules = true;
13 };
14
15 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
16 # Expects SDL2.framework in specific location, which we don't have
17 # Passing this in cmakeFlags doesn't work because the path is hard-coded for Darwin
18 substituteInPlace cmake/FindSDL2.cmake \
19 --replace 'set(SDL2_LIBRARIES' 'set(SDL2_LIBRARIES "${SDL2}/lib/libSDL2.dylib") #'
20 # Expects plutil, which we don't have
21 sed -i '/plutil/d' CMakeLists.txt
22 '';
23
24 buildInputs = [
25 SDL2
26 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
27 IOKit
28 Foundation
29 ];
30
31 nativeBuildInputs = [
32 cmake
33 makeWrapper
34 ];
35
36 cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [
37 "-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}"
38 # Expects SDL2.framework in specific location, which we don't have
39 "-DSDL2_INCLUDE_DIRS=${SDL2.dev}/include/SDL2"
40 ];
41
42 installPhase = ''
43 runHook preInstall
44
45 '' + (if stdenv.hostPlatform.isDarwin then ''
46 mkdir -p $out/{bin,Applications}
47 mv {,$out/Applications/}Bugdom.app
48 makeWrapper $out/{Applications/Bugdom.app/Contents/MacOS,bin}/Bugdom
49 '' else ''
50 mkdir -p $out/share/bugdom
51 mv Data $out/share/bugdom
52 install -Dm755 {.,$out/bin}/Bugdom
53 wrapProgram $out/bin/Bugdom --run "cd $out/share/bugdom"
54 install -Dm644 $src/packaging/bugdom.desktop $out/share/applications/bugdom.desktop
55 install -Dm644 $src/packaging/bugdom-desktopicon.png $out/share/pixmaps/bugdom-desktopicon.png
56 '') + ''
57
58 runHook postInstall
59 '';
60
61 meta = with lib; {
62 description = "A port of Bugdom, a 1999 Macintosh game by Pangea Software, for modern operating systems";
63 homepage = "https://github.com/jorio/Bugdom";
64 license = with licenses; [ cc-by-sa-40 ];
65 maintainers = with maintainers; [ lux ];
66 mainProgram = "Bugdom";
67 platforms = platforms.unix;
68 };
69}