1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00
nixpkgs/pkgs/games/warzone2100/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

147 lines
3.6 KiB
Nix

{ lib
, stdenv
, fetchurl
, cmake
, ninja
, p7zip
, pkg-config
, asciidoctor
, gettext
, SDL2
, libtheora
, libvorbis
, libopus
, openal
, openalSoft
, physfs
, miniupnpc
, libsodium
, curl
, libpng
, freetype
, harfbuzz
, sqlite
, which
, vulkan-headers
, vulkan-loader
, shaderc
, testers
, warzone2100
, nixosTests
, gitUpdater
, withVideos ? false
}:
let
pname = "warzone2100";
sequences_src = fetchurl {
url = "mirror://sourceforge/${pname}/warzone2100/Videos/high-quality-en/sequences.wz";
sha256 = "90ff552ca4a70e2537e027e22c5098ea4ed1bc11bb7fc94138c6c941a73d29fa";
};
in
stdenv.mkDerivation (finalAttrs: {
inherit pname;
version = "4.5.3";
src = fetchurl {
url = "mirror://sourceforge/project/warzone2100/releases/${finalAttrs.version}/warzone2100_src.tar.xz";
hash = "sha256-7tSfLkVth9nbGSwn1uNWeFrHx5ac+jaO3Gk9Bb+hLIk=";
};
buildInputs = [
SDL2
libtheora
libvorbis
libopus
openal
openalSoft
physfs
miniupnpc
libsodium
curl
libpng
freetype
harfbuzz
sqlite
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
vulkan-headers
vulkan-loader
];
nativeBuildInputs = [
pkg-config
cmake
ninja
p7zip
asciidoctor
gettext
shaderc
];
postPatch = ''
substituteInPlace lib/exceptionhandler/dumpinfo.cpp \
--replace '"which "' '"${which}/bin/which "'
substituteInPlace lib/exceptionhandler/exceptionhandler.cpp \
--replace "which %s" "${which}/bin/which %s"
'';
cmakeFlags = [
"-DWZ_DISTRIBUTOR=NixOS"
# The cmake builder automatically sets CMAKE_INSTALL_BINDIR to an absolute
# path, but this results in an error:
#
# > An absolute CMAKE_INSTALL_BINDIR path cannot be used if the following
# > are not also absolute paths: WZ_DATADIR
#
# WZ_DATADIR is based on CMAKE_INSTALL_DATAROOTDIR, so we set that.
#
# Alternatively, we could have set CMAKE_INSTALL_BINDIR to "bin".
"-DCMAKE_INSTALL_DATAROOTDIR=${placeholder "out"}/share"
] ++ lib.optional stdenv.hostPlatform.isDarwin "-P../configure_mac.cmake";
postInstall = lib.optionalString withVideos ''
cp ${sequences_src} $out/share/warzone2100/sequences.wz
'';
passthru.tests = {
version = testers.testVersion {
package = warzone2100;
# The command always exits with code 1
command = "(warzone2100 --version || [ $? -eq 1 ])";
};
nixosTest = nixosTests.warzone2100;
};
passthru.updateScript = gitUpdater {
url = "https://github.com/Warzone2100/warzone2100";
};
meta = with lib; {
description = "Free RTS game, originally developed by Pumpkin Studios";
mainProgram = "warzone2100";
longDescription = ''
Warzone 2100 is an open source real-time strategy and real-time tactics
hybrid computer game, originally developed by Pumpkin Studios and
published by Eidos Interactive.
In Warzone 2100, you command the forces of The Project in a battle to
rebuild the world after mankind has almost been destroyed by nuclear
missiles. The game offers campaign, multi-player, and single-player
skirmish modes. An extensive tech tree with over 400 different
technologies, combined with the unit design system, allows for a wide
variety of possible units and tactics.
'';
homepage = "https://wz2100.net";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ astsmtl fgaz ];
platforms = platforms.all;
# configure_mac.cmake tries to download stuff
# https://github.com/Warzone2100/warzone2100/blob/master/macosx/README.md
broken = stdenv.hostPlatform.isDarwin;
};
})