11{
22 lib ,
33 stdenv ,
4+ runCommand ,
45 fetchFromGitHub ,
56 cmake ,
7+ pkg-config ,
8+ imagemagick ,
9+ gtest ,
610 SDL2 ,
711 SDL2_mixer ,
812 freetype ,
1418 openal ,
1519 python3 ,
1620 zlib ,
17- } :
18-
19- let
2021 # the GLES backend on rpi is untested as I don't have the hardware
21- backend = if stdenv . hostPlatform . isx86 then "OpenGL" else "GLES" ;
22-
23- withVLC = stdenv . hostPlatform . isDarwin ;
22+ backend ? if stdenv . hostPlatform . isx86 then "OpenGL" else "GLES" ,
23+ } :
2424
25- inherit ( lib ) optional optionalString ;
25+ # Previously we only used libvlc *on* darwin, which is incorrect. According to
26+ # https://github.com/gemrb/gemrb/blob/master/INSTALL it is needed for some mac versions of some
27+ # games but there is obviously nothing wrong using those on linux.
28+ # Additionally, when gemrb adds support for the EE games, libvlc will be needed anyway.
2629
27- in
28- stdenv . mkDerivation rec {
29- pname = "gemrb" ;
30+ let
3031 version = "0.9.4" ;
3132
3233 src = fetchFromGitHub {
@@ -36,43 +37,58 @@ stdenv.mkDerivation rec {
3637 hash = "sha256-+aPnOJQGRblqcrblVU5ZwA8CZqeT19rxEtn3GLuofYU=" ;
3738 } ;
3839
40+ icons = runCommand "gemrb-icons" { nativeBuildInputs = [ imagemagick ] ; } ''
41+ for s in 48 64 96 128 256 512 1024; do
42+ size='' ${s}x'' ${s}
43+ dir=$out/share/icons/hicolor/$size
44+ mkdir -p $dir
45+ magick -background none -size $size ${ src } /artwork/logo04-rb_only.svg -format png $dir/gemrb.png
46+ done
47+ '' ;
48+
49+ in
50+ stdenv . mkDerivation ( finalAttrs : {
51+ pname = "gemrb" ;
52+ inherit version src ;
53+
3954 buildInputs = [
4055 SDL2
4156 SDL2_mixer
4257 freetype
4358 libGL
4459 libiconv
4560 libpng
61+ libvlc
4662 libvorbis
4763 openal
4864 python3
4965 zlib
50- ] ++ optional withVLC libvlc ;
51-
52- nativeBuildInputs = [ cmake ] ;
66+ ] ;
5367
54- # libvlc isn't being detected properly as of 0.9.0, so set it
55- LIBVLC_INCLUDE_PATH = optionalString withVLC "${ lib . getDev libvlc } /include" ;
56- LIBVLC_LIBRARY_PATH = optionalString withVLC "${ lib . getLib libvlc } /lib" ;
68+ nativeBuildInputs = [
69+ cmake
70+ pkg-config
71+ ] ++ lib . optionals ( finalAttrs . doCheck or false ) [ gtest ] ;
5772
5873 cmakeFlags = [
59- "-DDATA_DIR= ${ placeholder "out" } /share/gemrb"
60- "-DEXAMPLE_CONF_DIR= ${ placeholder "out" } /share/doc/gemrb/examples"
61- "-DSYSCONF_DIR= /etc"
74+ ( lib . cmakeFeature "DATA_DIR" " ${ placeholder "out" } /share/gemrb")
75+ ( lib . cmakeFeature "EXAMPLE_CONF_DIR" " ${ placeholder "out" } /share/doc/gemrb/examples")
76+ ( lib . cmakeFeature "SYSCONF_DIR" " /etc")
6277 # use the Mesa drivers for video on ARM (harmless on x86)
63- "-DDISABLE_VIDEOCORE=ON"
64- "-DLAYOUT=opt"
65- "-DOPENGL_BACKEND=${ backend } "
66- "-DOpenGL_GL_PREFERENCE=GLVND"
78+ ( lib . cmakeBool "DISABLE_VIDEOCORE" true )
79+ ( lib . cmakeFeature "LAYOUT" "opt" )
80+ ( lib . cmakeFeature "OPENGL_BACKEND" backend )
81+ ( lib . cmakeFeature "OpenGL_GL_PREFERENCE" "GLVND" )
82+ ( lib . cmakeBool "USE_TESTS" ( finalAttrs . doCheck or false ) )
6783 ] ;
6884
6985 postInstall = ''
70- for s in 36 48 72 96 144; do
71- install -Dm444 ../artwork/gemrb-logo-glow-'' ${s}px.png $out/share/icons/hicolor/'' ${s}x'' ${s}/gemrb.png
72- done
73- install -Dm444 ../artwork/gemrb-logo.png $out/share/icons/gemrb.png
86+ cp -r ${ icons } /share/icons $out/share/
7487 '' ;
7588
89+ # a bunch of tests fail in our sandbox
90+ doCheck = false ;
91+
7692 meta = with lib ; {
7793 description = "Reimplementation of the Infinity Engine, used by games such as Baldur's Gate" ;
7894 longDescription = ''
@@ -84,5 +100,6 @@ stdenv.mkDerivation rec {
84100 homepage = "https://gemrb.org/" ;
85101 license = licenses . gpl2Only ;
86102 maintainers = with maintainers ; [ peterhoeg ] ;
103+ mainProgram = "gemrb" ;
87104 } ;
88- }
105+ } )
0 commit comments