nixpkgs/pkgs/games/quakespasm/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

106 lines
3.5 KiB
Nix

{ lib, stdenv, SDL, SDL2, fetchurl, gzip, libvorbis, libmad, flac, libopus, opusfile, libogg, libxmp
, Cocoa, CoreAudio, CoreFoundation, IOKit, OpenGL
, copyDesktopItems, makeDesktopItem, pkg-config
, useSDL2 ? stdenv.hostPlatform.isDarwin # TODO: CoreAudio fails to initialize with SDL 1.x for some reason.
}:
stdenv.mkDerivation rec {
pname = "quakespasm";
version = "0.96.0";
src = fetchurl {
url = "mirror://sourceforge/quakespasm/quakespasm-${version}.tar.gz";
sha256 = "sha256-Sa4lLALB3xpMGVjpKnzGl1OBEJcLOHDcFGEFsO0wwOw=";
};
sourceRoot = "${pname}-${version}/Quake";
patches = lib.optionals stdenv.hostPlatform.isDarwin [
# Makes Darwin Makefile use system libraries instead of ones from app bundle
./quakespasm-darwin-makefile-improvements.patch
];
nativeBuildInputs = [
copyDesktopItems
pkg-config
];
buildInputs = [
gzip libvorbis libmad flac libopus opusfile libogg libxmp
(if useSDL2 then SDL2 else SDL)
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
Cocoa CoreAudio IOKit OpenGL
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && useSDL2) [
CoreFoundation
];
buildFlags = [
"DO_USERDIRS=1"
# Makefile defaults, set here to enforce consistency on Darwin build
"USE_CODEC_WAVE=1"
"USE_CODEC_MP3=1"
"USE_CODEC_VORBIS=1"
"USE_CODEC_FLAC=1"
"USE_CODEC_OPUS=1"
"USE_CODEC_MIKMOD=0"
"USE_CODEC_UMX=0"
"USE_CODEC_XMP=1"
"MP3LIB=mad"
"VORBISLIB=vorbis"
] ++ lib.optionals useSDL2 [
"SDL_CONFIG=sdl2-config"
"USE_SDL2=1"
];
makefile = if (stdenv.hostPlatform.isDarwin) then "Makefile.darwin" else "Makefile";
preInstall = ''
mkdir -p "$out/bin"
substituteInPlace Makefile --replace "/usr/local/games" "$out/bin"
substituteInPlace Makefile.darwin --replace "/usr/local/games" "$out/bin"
'';
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
# Let's build app bundle
mkdir -p $out/Applications/Quake.app/Contents/MacOS
mkdir -p $out/Applications/Quake.app/Contents/Resources
cp ../MacOSX/Info.plist $out/Applications/Quake.app/Contents/
cp ../MacOSX/QuakeSpasm.icns $out/Applications/Quake.app/Contents/Resources/
cp -r ../MacOSX/English.lproj $out/Applications/Quake.app/Contents/Resources/
ln -sf $out/bin/quake $out/Applications/Quake.app/Contents/MacOS/quake
substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
--replace '>''${EXECUTABLE_NAME}' '>quake'
substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
--replace '>''${PRODUCT_NAME}' '>QuakeSpasm'
'';
enableParallelBuilding = true;
desktopItems = [
(makeDesktopItem {
name = "quakespasm";
exec = "quake";
desktopName = "Quakespasm";
categories = [ "Game" ];
})
];
meta = with lib; {
description = "Engine for iD software's Quake";
homepage = "https://quakespasm.sourceforge.net/";
longDescription = ''
QuakeSpasm is a modern, cross-platform Quake 1 engine based on FitzQuake.
It includes support for 64 bit CPUs and custom music playback, a new sound driver,
some graphical niceities, and numerous bug-fixes and other improvements.
Quakespasm utilizes either the SDL or SDL2 frameworks, so choose which one
works best for you. SDL is probably less buggy, but SDL2 has nicer features
and smoother mouse input - though no CD support.
'';
platforms = platforms.unix;
maintainers = with maintainers; [ mikroskeem ];
mainProgram = "quake";
};
}