nixpkgs/pkgs/games/spring/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

65 lines
2.5 KiB
Nix

{ lib, stdenv, fetchFromGitHub, cmake, lzma, boost, libdevil, zlib, p7zip
, openal, libvorbis, glew, freetype, xorg, SDL2, libGLU, libGL
, asciidoc, docbook_xsl, docbook_xsl_ns, curl, makeWrapper
, jdk ? null, python ? null, systemd, libunwind, which, minizip
, withAI ? true # support for AI Interfaces and Skirmish AIs
}:
stdenv.mkDerivation rec {
pname = "spring";
version = "104.0.1-${buildId}-g${shortRev}";
# usually the latest in https://github.com/spring/spring/commits/maintenance
rev = "f266c8107b3e5dda5a78061ef00ca0ed8736d6f2";
shortRev = builtins.substring 0 7 rev;
buildId = "1486";
# taken from https://github.com/spring/spring/commits/maintenance
src = fetchFromGitHub {
owner = "spring";
repo = pname;
inherit rev;
sha256 = "1nx68d894yfmqc6df72hmk75ph26fqdvlmmq58cca0vbwpz9hf5v";
fetchSubmodules = true;
};
# The cmake included module correcly finds nix's glew, however
# it has to be the bundled FindGLEW for headless or dedicated builds
prePatch = ''
substituteInPlace ./rts/build/cmake/FindAsciiDoc.cmake \
--replace "PATHS /usr /usr/share /usr/local /usr/local/share" "PATHS ${docbook_xsl}"\
--replace "xsl/docbook/manpages" "share/xml/docbook-xsl/manpages"
substituteInPlace ./rts/Rendering/GL/myGL.cpp \
--replace "static constexpr const GLubyte* qcriProcName" "static const GLubyte* qcriProcName"
patchShebangs .
rm rts/build/cmake/FindGLEW.cmake
echo "${version} maintenance" > VERSION
'';
cmakeFlags = ["-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON"
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON"
"-DPREFER_STATIC_LIBS:BOOL=OFF"];
nativeBuildInputs = [ cmake makeWrapper docbook_xsl docbook_xsl_ns asciidoc ];
buildInputs = [ lzma boost libdevil zlib p7zip openal libvorbis freetype SDL2
xorg.libX11 xorg.libXcursor libGLU libGL glew curl
systemd libunwind which minizip ]
++ stdenv.lib.optional withAI jdk
++ stdenv.lib.optional withAI python;
NIX_CFLAGS_COMPILE = "-fpermissive"; # GL header minor incompatibility
postInstall = ''
wrapProgram "$out/bin/spring" \
--prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc systemd ]}"
'';
meta = with lib; {
homepage = "https://springrts.com/";
description = "A powerful real-time strategy (RTS) game engine";
license = licenses.gpl2;
maintainers = with maintainers; [ phreedom qknight domenkozar sorki ];
platforms = platforms.linux;
};
}