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