Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchpatch 5, fetchurl 6, bzip2 7, cmake 8, pkg-config 9, gettext 10, libsodium 11, SDL2 12, SDL_audiolib 13, SDL2_image 14, fmt 15, libpng 16, smpq 17}: 18 19let 20 # TODO: submit a PR upstream to allow system copies of these libraries where possible 21 22 # fork with patches, far behind upstream 23 asio = fetchurl { 24 url = "https://github.com/diasurgical/asio/archive/ebeff99f539da23d27c2e8d4bdbc1ee011968644.tar.gz"; 25 sha256 = "0vhb4cig40mm0a98i74grpmfkcmby8zxg6vqa38dpryxpgvp5fw8"; 26 }; 27 28 # fork with patches, upstream seems to be dead 29 libmpq = fetchurl { 30 url = "https://github.com/diasurgical/libmpq/archive/0f10bd1600f406b13932bf5351ba713361262184.tar.gz"; 31 sha256 = "sha256-7hc/Xtsg8WJIJljLydS7hLZA9lEEHWhsCteyrxK68qE="; 32 }; 33 34 # not "real" package with pkg-config or cmake file, just collection of source files 35 libsmackerdec = fetchurl { 36 url = "https://github.com/diasurgical/libsmackerdec/archive/2997ee0e41e91bb723003bc09234be553b190e38.tar.gz"; 37 sha256 = "sha256-QMDcIZQ94i4VPVanmSxiGkKgxWx82DP4uE+Q5I2nU+o="; 38 }; 39 40 # fork with patches, far behind upstream 41 libzt = fetchFromGitHub { 42 owner = "diasurgical"; 43 repo = "libzt"; 44 fetchSubmodules = true; 45 rev = "37a2efb0b925df632299ef07dc78c0af5f6b4756"; 46 sha256 = "sha256-+o4ZTVqh4MDZES9m7mkfkMRlRDMBytDBuA0QIlnp73U="; 47 }; 48 49 # missing pkg-config and/or cmake file 50 simpleini = fetchurl { 51 url = "https://github.com/brofield/simpleini/archive/9b3ed7ec815997bc8c5b9edf140d6bde653e1458.tar.gz"; 52 sha256 = "sha256-93kuyp8/ew7okW/6ThJMtLMZsR1YSeFcXu9Y65ELBFE=="; 53 }; 54in 55 56stdenv.mkDerivation rec { 57 pname = "devilutionx"; 58 version = "1.4.1"; 59 60 src = fetchFromGitHub { 61 owner = "diasurgical"; 62 repo = "devilutionX"; 63 rev = version; 64 sha256 = "sha256-l0BhL+DXtkG2PdFqmkL0KJv41zl3N/AcuLmzw2j3jXY="; 65 }; 66 67 postPatch = '' 68 substituteInPlace Source/init.cpp --replace "/usr/share/diasurgical/devilutionx/" "${placeholder "out"}/share/diasurgical/devilutionx/" 69 70 # download dependencies ahead of time 71 substituteInPlace 3rdParty/asio/CMakeLists.txt --replace "${asio.url}" "${asio}" 72 substituteInPlace 3rdParty/libmpq/CMakeLists.txt --replace "${libmpq.url}" "${libmpq}" 73 substituteInPlace 3rdParty/libsmackerdec/CMakeLists.txt --replace "${libsmackerdec.url}" "${libsmackerdec}" 74 substituteInPlace 3rdParty/libzt/CMakeLists.txt \ 75 --replace "GIT_REPOSITORY https://github.com/diasurgical/libzt.git" "" \ 76 --replace "GIT_TAG ${libzt.rev}" "SOURCE_DIR ${libzt}" 77 substituteInPlace 3rdParty/simpleini/CMakeLists.txt --replace "${simpleini.url}" "${simpleini}" 78 ''; 79 80 cmakeFlags = [ 81 "-DBINARY_RELEASE=ON" 82 "-DVERSION_NUM=${version}" 83 ]; 84 85 nativeBuildInputs = [ 86 cmake 87 pkg-config 88 gettext 89 smpq # used to build devilutionx.mpq 90 ]; 91 92 buildInputs = [ 93 bzip2 94 fmt 95 libpng 96 libsodium 97 SDL2 98 SDL_audiolib 99 SDL2_image 100 ]; 101 102 installPhase = '' 103 runHook preInstall 104 105 '' + (if stdenv.isDarwin then '' 106 mkdir -p $out/Applications 107 mv devilutionx.app $out/Applications 108 '' else '' 109 install -Dm755 -t $out/bin devilutionx 110 install -Dm755 -t $out/share/diasurgical/devilutionx devilutionx.mpq 111 install -Dm755 -t $out/share/applications ../Packaging/nix/devilutionx-hellfire.desktop ../Packaging/nix/devilutionx.desktop 112 install -Dm755 ../Packaging/resources/icon.png $out/share/icons/hicolor/512x512/apps/devilutionx.png 113 install -Dm755 ../Packaging/resources/hellfire.png $out/share/icons/hicolor/512x512/apps/devilutionx-hellfire.png 114 install -Dm755 ../Packaging/resources/icon_32.png $out/share/icons/hicolor/32x32/apps/devilutionx.png 115 install -Dm755 ../Packaging/resources/hellfire_32.png $out/share/icons/hicolor/32x32/apps/devilutionx-hellfire.png 116 '') + '' 117 118 runHook postInstall 119 ''; 120 121 meta = with lib; { 122 homepage = "https://github.com/diasurgical/devilutionX"; 123 description = "Diablo build for modern operating systems"; 124 longDescription = "In order to play this game a copy of diabdat.mpq is required. Place a copy of diabdat.mpq in ~/.local/share/diasurgical/devilution before executing the game."; 125 license = licenses.unlicense; 126 maintainers = with maintainers; [ karolchmist aanderse ]; 127 platforms = platforms.linux ++ platforms.windows; 128 }; 129}