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