anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / games / speed-dreams / default.nix
blobf81c2f7f2f341e8074c1aaed0c172e016f1137ca
1 { fetchurl, lib, stdenv, libGLU, libGL, libglut, libX11, plib, openal, freealut, libXrandr, xorgproto,
2 libXext, libSM, libICE, libXi, libXt, libXrender, libXxf86vm, openscenegraph, expat,
3 libpng, zlib, bash, SDL2, SDL2_mixer, enet, libjpeg, cmake, pkg-config, libvorbis, runtimeShell, curl, copyDesktopItems, makeDesktopItem }:
5 let
6   version = "2.3.0-r8786";
7   shortVersion = builtins.substring 0 5 version;
8 in
9 stdenv.mkDerivation rec {
10   inherit version;
11   pname = "speed-dreams";
13   src = fetchurl {
14     url = "mirror://sourceforge/speed-dreams/${shortVersion}/speed-dreams-src-base-${version}.tar.xz";
15     sha256 = "sha256-DUyMs9Hr1PYgmNVwBY/e6snVeGl9GX0AnZ7S+TFABKQ=";
16   };
18   cars-and-tracks = fetchurl {
19     url = "mirror://sourceforge/speed-dreams/${shortVersion}/speed-dreams-src-hq-cars-and-tracks-${version}.tar.xz";
20     sha256 = "sha256-WT+W6uuw4BRSbF1Cw123q3v9qSCvBQ7TcQ/Y0RV/7Js=";
21   };
23   more-cars-and-tracks = fetchurl {
24     url = "mirror://sourceforge/speed-dreams/${shortVersion}/speed-dreams-src-more-hq-cars-and-tracks-${version}.tar.xz";
25     sha256 = "sha256-psApv+Z1HDFvh5bzt125mo/ZvO5rjee/KhOf45iKnKk=";
26   };
28   wip-cars-and-tracks = fetchurl {
29     url = "mirror://sourceforge/speed-dreams/${shortVersion}/speed-dreams-src-wip-cars-and-tracks-${version}.tar.xz";
30     sha256 = "sha256-OEAbqFfO2PzHP7+eAtPNn3Ql6fYNTKzzQW8lHe9KDXM=";
31   };
33   sourceRoot = ".";
35   postUnpack = ''
36     echo Unpacking data
37     tar -xf ${cars-and-tracks}
38     tar -xf ${more-cars-and-tracks}
39     tar -xf ${wip-cars-and-tracks}
40   '';
42   preBuild = ''
43     make -C src/libs/portability
44     make -C src/libs/portability portability.o
45     ar -rv "$(echo lib*/games/speed-dreams*/lib)"/libportability_static.a src/libs/portability/CMakeFiles/portability.dir/portability.cpp.o
46     export NIX_LDFLAGS="$NIX_LDFLAGS -L$(echo $PWD/lib*/games/speed-dreams*/lib) -lexpat"
47     echo "libportability_static.a built"
48   '';
50   postInstall = ''
51     mkdir "$out/bin"
52     for i in "$out"/games/*; do
53       echo '#!${runtimeShell}' >> "$out/bin/$(basename "$i")"
54       echo "$i"' "$@"' >> "$out/bin/$(basename "$i")"
55       chmod a+x "$out/bin/$(basename "$i")"
56     done
58     mkdir -p $out/share/pixmaps/
59     ln -s "$out/share/games/speed-dreams-2/data/icons/icon.png" "$out/share/pixmaps/speed-dreams-2.png"
60   '';
62   desktopItems = [
63     (makeDesktopItem {
64       name = "Speed Dreams 2";
65       exec = "speed-dreams-2";
66       icon = "speed-dreams-2.png";
67       desktopName = "speed-dreams-2";
68       comment = "The Open Racing Car Simulator Fork";
69       categories = [ "Application" "Game" ];
70     })
71   ];
73   # RPATH of binary /nix/store/.../lib64/games/speed-dreams-2/drivers/shadow_sc/shadow_sc.so contains a forbidden reference to /build/
74   cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=ON" ];
76   nativeBuildInputs = [ pkg-config cmake copyDesktopItems ];
78   buildInputs = [ libpng libGLU libGL libglut libX11 plib openal freealut libXrandr xorgproto
79     libXext libSM libICE libXi libXt libXrender libXxf86vm zlib bash expat
80     SDL2 SDL2_mixer enet libjpeg openscenegraph libvorbis curl ];
82   meta = {
83     description = "Car racing game - TORCS fork with more experimental approach";
84     homepage = "https://speed-dreams.sourceforge.net/";
85     license = lib.licenses.gpl2Plus;
86     maintainers = with lib.maintainers; [raskin];
87     platforms = lib.platforms.linux;
88     hydraPlatforms = [];
89   };