nixpkgs-suyu/pkgs/games/quake2/yquake2/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

93 lines
2.6 KiB
Nix

{ stdenv, lib, fetchFromGitHub, buildEnv, cmake, makeWrapper
, SDL2, libGL, curl
, oggSupport ? true, libogg, libvorbis
, openalSupport ? true, openal
, zipSupport ? true, zlib
, Cocoa, OpenAL
}:
let
mkFlag = b: if b then "ON" else "OFF";
games = import ./games.nix { inherit stdenv lib fetchFromGitHub cmake; };
wrapper = import ./wrapper.nix { inherit stdenv lib buildEnv makeWrapper yquake2; };
yquake2 = stdenv.mkDerivation rec {
pname = "yquake2";
version = "7.43";
src = fetchFromGitHub {
owner = "yquake2";
repo = "yquake2";
rev = "QUAKE2_${builtins.replaceStrings ["."] ["_"] version}";
sha256 = "1dszbvxlh1npq4nv9s4wv4lcyfgb01k92ncxrrczsxy1dddg86pp";
};
nativeBuildInputs = [ cmake ];
buildInputs = [ SDL2 libGL curl ]
++ lib.optionals stdenv.isDarwin [ Cocoa OpenAL ]
++ lib.optionals oggSupport [ libogg libvorbis ]
++ lib.optional openalSupport openal
++ lib.optional zipSupport zlib;
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DOGG_SUPPORT=${mkFlag oggSupport}"
"-DOPENAL_SUPPORT=${mkFlag openalSupport}"
"-DZIP_SUPPORT=${mkFlag zipSupport}"
"-DSYSTEMWIDE_SUPPORT=ON"
];
preConfigure = ''
# Since we can't expand $out in `cmakeFlags`
cmakeFlags="$cmakeFlags -DSYSTEMDIR=$out/share/games/quake2"
'';
installPhase = ''
# Yamagi Quake II expects all binaries (executables and libs) to be in the
# same directory.
mkdir -p $out/bin $out/lib/yquake2 $out/share/games/quake2
cp -r release/* $out/lib/yquake2
ln -s $out/lib/yquake2/quake2 $out/bin/yquake2
ln -s $out/lib/yquake2/q2ded $out/bin/yq2ded
cp $src/stuff/yq2.cfg $out/share/games/quake2
'';
meta = with lib; {
description = "Yamagi Quake II client";
homepage = "https://www.yamagi.org/quake2/";
license = licenses.gpl2;
platforms = platforms.unix;
maintainers = with maintainers; [ tadfisher ];
};
};
in {
inherit yquake2;
yquake2-ctf = wrapper {
games = [ games.ctf ];
name = "yquake2-ctf";
inherit (games.ctf) description;
};
yquake2-ground-zero = wrapper {
games = [ games.ground-zero ];
name = "yquake2-ground-zero";
inherit (games.ground-zero) description;
};
yquake2-the-reckoning = wrapper {
games = [ games.the-reckoning ];
name = "yquake2-the-reckoning";
inherit (games.the-reckoning) description;
};
yquake2-all-games = wrapper {
games = lib.attrValues games;
name = "yquake2-all-games";
description = "Yamagi Quake II with all add-on games";
};
}