summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/to/torcs/package.nix
blob: 9ab747770b84257a058d9b273ff97acaa51e3158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  imagemagick,
  stdenv,
  symlinkJoin,
  torcs-without-data,
}:
let
  # This package is split into two parts because the complete package includes
  # the game data, which takes up a lot of space and is not worth serving from
  # the official cache. The compiled program gets built by Hydra and cached,
  # while the game data does not and gets handled locally instead.
  torcs-data = stdenv.mkDerivation (finalAttrs: {
    pname = "torcs-data";
    inherit (torcs-without-data)
      version
      src
      buildInputs
      ;

    dontBuild = true;

    installTargets = "export datainstall";
    postInstall = ''
      mkdir -p $out/share/icons/hicolor/64x64/apps
      ${imagemagick}/bin/magick Ticon.png -resize 64x64 $out/share/icons/hicolor/64x64/apps/torcs.png

      substituteInPlace torcs.desktop \
        --replace-fail "Icon=torcs.png" "Icon=torcs"
      install -D -m644 torcs.desktop $out/share/applications/torcs.desktop
    '';

    meta.hydraPlatforms = [ ];
  });
in
symlinkJoin {
  pname = "torcs";
  inherit (torcs-without-data)
    version
    ;

  paths = [
    torcs-without-data
    torcs-data
  ];

  postBuild = ''
    cp --remove-destination $(realpath $out/bin/torcs) $out/bin/torcs
    substituteInPlace $out/bin/torcs \
      --replace-fail "${torcs-without-data}" "$out"
  '';

  meta = torcs-without-data.meta // {
    description = "Car racing game";
    hydraPlatforms = [ ];
  };
}