diff --git a/pkgs/by-name/od/odamex/package.nix b/pkgs/by-name/od/odamex/package.nix index bdd7e84f33e2..b0031195ed9e 100644 --- a/pkgs/by-name/od/odamex/package.nix +++ b/pkgs/by-name/od/odamex/package.nix @@ -1,62 +1,218 @@ { lib, stdenv, - fetchurl, + fetchFromGitHub, + fetchpatch, + cmake, - pkg-config, + copyDesktopItems, + deutex, + makeDesktopItem, makeWrapper, - SDL, - SDL_mixer, - SDL_net, + pkg-config, + wrapGAppsHook3, + + SDL2, + SDL2_mixer, + SDL2_net, + alsa-lib, + cpptrace, + curl, + expat, + fltk, + libdwarf, + libselinux, + libsepol, + libsysprof-capture, + libuuid, + libxdmcp, + libxkbcommon, + pcre2, + portmidi, + wayland-scanner, + waylandpp, wxGTK32, + xorg, + zstd, + + nix-update-script, + + withX11 ? stdenv.hostPlatform.isLinux, + withWayland ? stdenv.hostPlatform.isLinux, }: -stdenv.mkDerivation rec { - pname = "odamex"; - version = "0.9.5"; - - src = fetchurl { - url = "mirror://sourceforge/${pname}/${pname}-src-${version}.tar.bz2"; - sha256 = "sha256-WBqO5fWzemw1kYlY192v0nnZkbIEVuWmjWYMy+1ODPQ="; +let + # TODO: remove when this is resolved, likely at the next cpptrace bump + cpptrace' = cpptrace.overrideAttrs { + # tests are failing on darwin + # https://hydra.nixos.org/build/310535948 + doCheck = !stdenv.hostPlatform.isDarwin; }; +in + +stdenv.mkDerivation (finalAttrs: { + pname = "odamex"; + version = "11.1.1"; + + src = fetchFromGitHub { + owner = "odamex"; + repo = "odamex"; + tag = finalAttrs.version; + hash = "sha256-UUUavIaU65vU80Bp2cVjHg8IubpA6qMqZmDYvTDjfEw="; + fetchSubmodules = true; + }; + + patches = [ + # fix file-open panel on Darwin + # https://github.com/odamex/odamex/pull/1402 + # TODO: remove on next release + (fetchpatch { + url = "https://patch-diff.githubusercontent.com/raw/odamex/odamex/pull/1402.patch"; + hash = "sha256-JrcQ0rYkaFP5aKNWeXbrY2TN4r8nHpue19qajNXJXg4="; + }) + ]; nativeBuildInputs = [ cmake - pkg-config + copyDesktopItems + deutex makeWrapper + pkg-config + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + wrapGAppsHook3 ]; buildInputs = [ - SDL - SDL_mixer - SDL_net + SDL2 + SDL2_mixer + SDL2_net + cpptrace' + curl + expat + fltk + libdwarf + libsysprof-capture + pcre2 + portmidi wxGTK32 + zstd + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + alsa-lib + libselinux + libuuid + libxdmcp + libsepol + ] + ++ lib.optionals withX11 [ + xorg.libX11 + xorg.xorgproto + ] + ++ lib.optionals withWayland [ + libxkbcommon + wayland-scanner + waylandpp + ]; + + cmakeFlags = [ + (lib.cmakeBool "USE_INTERNAL_CPPTRACE" false) + (lib.cmakeFeature "ODAMEX_INSTALL_BINDIR" "$ODAMEX_BINDIR") # set by wrapper ]; installPhase = '' runHook preInstall - '' - + ( - if stdenv.hostPlatform.isDarwin then - '' - mkdir -p $out/{Applications,bin} - mv odalaunch/odalaunch.app $out/Applications - makeWrapper $out/{Applications/odalaunch.app/Contents/MacOS,bin}/odalaunch - '' - else - '' - make install - '' - ) - + '' + + ${ + if stdenv.hostPlatform.isDarwin then + # bash + '' + mkdir -p $out/{Applications,bin} + + mv client odamex + for name in odamex odalaunch; do + contents="Applications/$name.app/Contents/MacOS" + mv $name/*.app $out/Applications + makeWrapper $out/{"$contents",bin}/"$name" \ + --set ODAMEX_BINDIR "${placeholder "out"}/Applications" + done + + cp server/odasrv $out/Applications + ln -s $out/Applications/odamex.app/Contents/MacOS/odamex.wad $out/Applications + makeWrapper $out/{Applications,bin}/odasrv + '' + else + # bash + '' + make install + + # copy desktop file icons + for name in odamex odalaunch odasrv; do + for size in 96 128 256 512; do + install -Dm644 ../media/icon_"$name"_"$size".png \ + $out/share/icons/hicolor/"$size"x"$size"/"$name".png + done + + install -Dm644 ../media/icon_"$name"_128.png \ + $out/share/pixmaps/"$name".png + done + '' + } + runHook postInstall ''; + preFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + gappsWrapperArgs+=( + --set ODAMEX_BINDIR "${placeholder "out"}/bin" + ) + ''; + + desktopItems = [ + (makeDesktopItem { + name = "odamex"; + icon = "odamex"; + exec = "odamex"; + desktopName = "Odamex Client"; + comment = "A Doom multiplayer game engine"; + categories = [ + "ActionGame" + "Game" + "Shooter" + ]; + }) + (makeDesktopItem { + name = "odalaunch"; + icon = "odalaunch"; + exec = "odalaunch"; + desktopName = "Odamex Launcher"; + comment = "Server Browser for Odamex"; + categories = [ + "ActionGame" + "Game" + "Shooter" + ]; + }) + (makeDesktopItem { + name = "odasrv"; + icon = "odasrv"; + exec = "odasrv"; + desktopName = "Odamex Server"; + comment = "Run an Odamex game server"; + categories = [ + "Network" + ]; + }) + ]; + + passthru.updateScript = nix-update-script { }; + meta = { homepage = "http://odamex.net/"; description = "Client/server port for playing old-school Doom online"; license = lib.licenses.gpl2Only; platforms = lib.platforms.unix; - maintainers = [ ]; + maintainers = with lib.maintainers; [ eljamm ]; + mainProgram = "odalaunch"; }; -} +})