Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 81 lines 2.0 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 fetchzip, 6 SDL_compat, 7 SDL_mixer, 8 makeDesktopItem, 9 copyDesktopItems, 10 unzip, 11 buildShareware ? false, 12 withSharewareData ? buildShareware, 13}: 14assert withSharewareData -> buildShareware; 15 16let 17 datadir = "share/data/rott-shareware/"; 18in 19stdenv.mkDerivation (finalAttrs: { 20 pname = "rott"; 21 version = "1.1.2"; 22 23 __structuredAttrs = true; 24 srcs = [ 25 (fetchurl { 26 url = "https://icculus.org/rott/releases/${finalAttrs.pname}-${finalAttrs.version}.tar.gz"; 27 hash = "sha256-ECUW6MMS9rC79sYj4fAcv7vDFKzorf4fIB1HsVvZJ/8="; 28 }) 29 ] 30 ++ lib.optional withSharewareData (fetchzip { 31 url = "http://icculus.org/rott/share/1rott13.zip"; 32 hash = "sha256-l0pP+mNPAabGh7LZrwcB6KOhPRSycrZpAlPVTyDXc6Y="; 33 stripRoot = false; 34 }); 35 36 sourceRoot = "rott-${finalAttrs.version}/rott"; 37 38 nativeBuildInputs = [ copyDesktopItems ] ++ lib.optional withSharewareData unzip; 39 40 buildInputs = [ 41 SDL_compat 42 SDL_mixer 43 ]; 44 45 enableParallelBuilding = true; 46 47 makeFlags = [ 48 "SHAREWARE=${if buildShareware then "1" else "0"}" 49 ''EXTRACFLAGS=-DDATADIR=\"${if withSharewareData then "${placeholder "out"}/${datadir}" else ""}\"'' 50 ]; 51 52 installPhase = '' 53 runHook preInstall 54 55 ${lib.optionalString withSharewareData '' 56 mkdir -p "$out/${datadir}" 57 unzip -d "$out/${datadir}" ../../source/ROTTSW13.SHR 58 ''} 59 install -Dm755 -t $out/bin rott 60 61 runHook postInstall 62 ''; 63 64 desktopItems = [ 65 (makeDesktopItem { 66 name = "rott"; 67 exec = "rott"; 68 desktopName = "Rise of the Triad: ${if buildShareware then "The HUNT Begins" else "Dark War"}"; 69 categories = [ "Game" ]; 70 }) 71 ]; 72 73 meta = { 74 description = "SDL port of Rise of the Triad"; 75 mainProgram = "rott"; 76 homepage = "https://icculus.org/rott/"; 77 license = with lib.licenses; [ gpl2Plus ] ++ lib.optional withSharewareData unfreeRedistributable; 78 maintainers = with lib.maintainers; [ sander ]; 79 platforms = lib.platforms.all; 80 }; 81})