|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + copyDesktopItems, |
| 5 | + fetchFromGitLab, |
| 6 | + fetchpatch, |
| 7 | + pkg-config, |
| 8 | + luajit_2_0, |
| 9 | + libGL, |
| 10 | + libGLU, |
| 11 | + alsa-lib, |
| 12 | + xorg, |
| 13 | + glfw2, |
| 14 | + glfw3, |
| 15 | + useGlfw3 ? false, |
| 16 | +}: |
| 17 | + |
| 18 | +stdenv.mkDerivation { |
| 19 | + pname = "pax-britannica"; |
| 20 | + version = "1.0.0-5"; |
| 21 | + |
| 22 | + src = fetchFromGitLab { |
| 23 | + domain = "salsa.debian.org"; |
| 24 | + owner = "games-team"; |
| 25 | + repo = "pax-britannica"; |
| 26 | + rev = "00ccbac5"; |
| 27 | + hash = "sha256-j69di+3P+vaFzv8Zke1MdABMkLtknTNvlfPk1YVUfmU="; |
| 28 | + }; |
| 29 | + |
| 30 | + patches = |
| 31 | + [ |
| 32 | + (fetchpatch { |
| 33 | + url = "https://sources.debian.org/data/main/p/pax-britannica/1.0.0-5/debian/patches/compile_for_linux.patch"; |
| 34 | + hash = "sha256-XncjmJrBakz5/w90O6rDif2rWSoAVKzuPEj9wN2VNvQ="; |
| 35 | + }) |
| 36 | + (fetchpatch { |
| 37 | + url = "https://sources.debian.org/data/main/p/pax-britannica/1.0.0-5/debian/patches/add_manpage.patch"; |
| 38 | + hash = "sha256-c8O6t0Zv/ln7WiPdbN3sYGsb7SL9Rmeo+94DsjpfgvY="; |
| 39 | + }) |
| 40 | + (fetchpatch { |
| 41 | + url = "https://sources.debian.org/data/main/p/pax-britannica/1.0.0-5/debian/patches/load_resources_from_usr_share.patch"; |
| 42 | + hash = "sha256-61Yt4Rq1I/Ofu640XsDDo0il275B+ozqH0Z6P18XT6Q="; |
| 43 | + }) |
| 44 | + (fetchpatch { |
| 45 | + url = "https://sources.debian.org/data/main/p/pax-britannica/1.0.0-5/debian/patches/add_desktop_entry.patch"; |
| 46 | + hash = "sha256-QSQEBoCw7KTOLgy7TaFvQRpR17HoggTOCxhfTG+kIOA="; |
| 47 | + }) |
| 48 | + ] |
| 49 | + ++ lib.optional useGlfw3 (fetchpatch { |
| 50 | + url = "https://sources.debian.org/data/main/p/pax-britannica/1.0.0-5/debian/patches/glfw3.patch"; |
| 51 | + hash = "sha256-hj00vnW/i7lxFc4CGlRz6Havkg45gGgIg6MmCXcMsSg="; |
| 52 | + }); |
| 53 | + postPatch = '' |
| 54 | + substituteInPlace Makefile \ |
| 55 | + --replace-fail '-DEXTRA_LOADERS=\"../extra_loaders.h\"' '-DEXTRA_LOADERS=\\\"../extra_loaders.h\\\"' |
| 56 | + substituteInPlace dokidoki-support/Makefile \ |
| 57 | + --replace-fail '$(STATIC_LINK)' "" \ |
| 58 | + --replace-fail '-llua' '-lluajit-5.1' |
| 59 | + substituteInPlace dokidoki-support/minlua.c \ |
| 60 | + --replace-fail /usr/share/pax-britannica $out/share/pax-britannica |
| 61 | + ''; |
| 62 | + |
| 63 | + nativeBuildInputs = [ |
| 64 | + pkg-config |
| 65 | + copyDesktopItems |
| 66 | + ]; |
| 67 | + buildInputs = [ |
| 68 | + luajit_2_0 |
| 69 | + libGL |
| 70 | + libGLU |
| 71 | + alsa-lib |
| 72 | + xorg.libX11 |
| 73 | + xorg.libXrandr |
| 74 | + (if useGlfw3 then glfw3 else glfw2) |
| 75 | + ]; |
| 76 | + makeFlags = |
| 77 | + if stdenv.hostPlatform.isLinux then |
| 78 | + [ "linux" ] |
| 79 | + else if stdenv.hostPlatform.isDarwin then |
| 80 | + [ "macosx" ] |
| 81 | + else if stdenv.hostPlatform.isMinGW then |
| 82 | + [ "mingw" ] |
| 83 | + else |
| 84 | + throw "Unsupported hostPlatform"; |
| 85 | + |
| 86 | + preBuild = '' |
| 87 | + makeFlagsArray+=( |
| 88 | + EXTRA_LDFLAGS="$(pkg-config --libs alsa x11 xrandr)" |
| 89 | + ) |
| 90 | + ''; |
| 91 | + |
| 92 | + desktopItems = [ "pax-britannica.desktop" ]; |
| 93 | + |
| 94 | + installPhase = '' |
| 95 | + mkdir -p $out/{bin,share/pax-britannica,share/pixmaps} |
| 96 | + cp -ar *.lua audio components dokidoki scripts sprites $out/share/pax-britannica/ |
| 97 | + cp pax-britannica.png $out/share/pixmaps/ |
| 98 | + cp pax-britannica $out/bin/ |
| 99 | + ''; |
| 100 | + |
| 101 | + meta = { |
| 102 | + description = "One-button multi-player real-time strategy game"; |
| 103 | + homepage = "http://gangles.ca/games/pax-britannica/"; |
| 104 | + license = lib.licenses.mit; |
| 105 | + maintainers = with lib.maintainers; [ astro ]; |
| 106 | + platforms = with lib.platforms; linux ++ darwin ++ windows; |
| 107 | + mainProgram = "pax-britannica"; |
| 108 | + }; |
| 109 | +} |
0 commit comments