Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv 2, makeWrapper 3, makeDesktopItem, copyDesktopItems 4, fetchFromGitHub 5, pkg-config 6, SDL2, SDL2_image 7}: 8 9stdenv.mkDerivation rec { 10 pname = "sdlpop"; 11 version = "1.23"; 12 13 src = fetchFromGitHub { 14 owner = "NagyD"; 15 repo = "SDLPoP"; 16 rev = "v${version}"; 17 sha256 = "sha256-UI7NfOC/+druRYL5g2AhIjTPEq4ta1qEThcxgyrFjHY="; 18 }; 19 20 nativeBuildInputs = [ pkg-config makeWrapper copyDesktopItems ]; 21 22 buildInputs = [ SDL2 SDL2_image ]; 23 24 makeFlags = [ "-C" "src" ]; 25 26 preBuild = '' 27 substituteInPlace src/Makefile \ 28 --replace "CC = gcc" "CC = ${stdenv.cc.targetPrefix}cc" \ 29 --replace "CFLAGS += -I/opt/local/include" "CFLAGS += -I${SDL2.dev}/include/SDL2 -I${SDL2_image}/include/SDL2" 30 ''; 31 32 # The prince binary expects two things of the working directory it is called from: 33 # (1) There is a subdirectory "data" containing the level data. 34 # (2) The working directory is writable, so save and quicksave files can be created. 35 # Our solution is to ensure that ~/.local/share/sdlpop is the working 36 # directory, symlinking the data files into it. This is the task of the 37 # prince.sh wrapper. 38 39 installPhase = '' 40 runHook preInstall 41 42 install -Dm755 prince $out/bin/.prince-bin 43 substituteAll ${./prince.sh} $out/bin/prince 44 chmod +x $out/bin/prince 45 46 mkdir -p $out/share/sdlpop 47 cp -r data doc mods SDLPoP.ini $out/share/sdlpop 48 49 install -Dm755 data/icon.png $out/share/icons/hicolor/32x32/apps/sdlpop.png 50 51 runHook postInstall 52 ''; 53 54 desktopItems = [ (makeDesktopItem { 55 name = "sdlpop"; 56 icon = "sdlpop"; 57 exec = "prince"; 58 desktopName = "SDLPoP"; 59 comment = "An open-source port of Prince of Persia"; 60 categories = [ "Game" "AdventureGame" ]; 61 }) ]; 62 63 meta = with lib; { 64 description = "Open-source port of Prince of Persia"; 65 homepage = "https://github.com/NagyD/SDLPoP"; 66 changelog = "https://github.com/NagyD/SDLPoP/blob/v${version}/doc/ChangeLog.txt"; 67 license = licenses.gpl3Plus; 68 maintainers = with maintainers; [ iblech ]; 69 platforms = platforms.unix; 70 mainProgram = "prince"; 71 }; 72}