Commit 73fa6990 authored by langsjo's avatar langsjo
Browse files

torcs: split compilation and installing data into separate derivations

This allows for the compilation result of the package to be built and
cached by Hydra, while not needing to keep all the data of the package
in the cache.
parent 60dbab5d
Loading
Loading
Loading
Loading
+39 −72
Original line number Diff line number Diff line
{
  fetchpatch,
  fetchurl,
  lib,
  stdenv,
  libGLU,
  libglut,
  libX11,
  plib,
  openal,
  freealut,
  libXrandr,
  xorgproto,
  libXext,
  libsm,
  libice,
  libXi,
  libXt,
  libXrender,
  libXxf86vm,
  libvorbis,
  libpng,
  zlib,
  makeWrapper,
  symlinkJoin,
  torcs-without-data,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "torcs";
  version = "1.3.8";

  src = fetchurl {
    url = "mirror://sourceforge/torcs/torcs-${finalAttrs.version}.tar.bz2";
    sha256 = "sha256-S5Z3NUX7NkEZgqbziXIF64/VciedTOVp8s4HsI6Jp68=";
  };

  patches = [
    (fetchpatch {
      url = "https://salsa.debian.org/games-team/torcs/raw/fb0711c171b38c4648dc7c048249ec20f79eb8e2/debian/patches/format-argument.patch";
      sha256 = "04advcx88yh23ww767iysydzhp370x7cqp2wf9hk2y1qvw7mxsja";
    })
  ];

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 = ''
      install -D -m644 Ticon.png $out/share/pixmaps/torcs.png
      install -D -m644 torcs.desktop $out/share/applications/torcs.desktop
    '';

  postPatch = ''
    sed -i -e s,/bin/bash,`type -P bash`, src/linux/torcs.in
  '';
    meta.hydraPlatforms = [ ];
  });
in
symlinkJoin {
  pname = "torcs";
  inherit (torcs-without-data)
    version
    ;

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [
    libGLU
    libglut
    libX11
    plib
    openal
    freealut
    libXrandr
    xorgproto
    libXext
    libsm
    libice
    libXi
    libXt
    libXrender
    libXxf86vm
    libpng
    zlib
    libvorbis
  paths = [
    torcs-without-data
    torcs-data
  ];

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

  meta = {
  meta = torcs-without-data.meta // {
    description = "Car racing game";
    homepage = "https://torcs.sourceforge.net/";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ pixel-87 ];
    platforms = lib.platforms.linux;
    hydraPlatforms = [ ];
  };
})
}
+74 −0
Original line number Diff line number Diff line
{
  fetchpatch,
  fetchurl,
  lib,
  stdenv,
  libGLU,
  libglut,
  libX11,
  plib,
  openal,
  freealut,
  libXrandr,
  xorgproto,
  libXext,
  libsm,
  libice,
  libXi,
  libXt,
  libXrender,
  libXxf86vm,
  libvorbis,
  libpng,
  zlib,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "torcs-without-data";
  version = "1.3.8";

  src = fetchurl {
    url = "mirror://sourceforge/torcs/torcs-${finalAttrs.version}.tar.bz2";
    sha256 = "sha256-S5Z3NUX7NkEZgqbziXIF64/VciedTOVp8s4HsI6Jp68=";
  };

  patches = [
    (fetchpatch {
      url = "https://salsa.debian.org/games-team/torcs/raw/fb0711c171b38c4648dc7c048249ec20f79eb8e2/debian/patches/format-argument.patch";
      sha256 = "04advcx88yh23ww767iysydzhp370x7cqp2wf9hk2y1qvw7mxsja";
    })
  ];

  postPatch = ''
    sed -i -e s,/bin/bash,`type -P bash`, src/linux/torcs.in
  '';

  buildInputs = [
    libGLU
    libglut
    libX11
    plib
    openal
    freealut
    libXrandr
    xorgproto
    libXext
    libsm
    libice
    libXi
    libXt
    libXrender
    libXxf86vm
    libpng
    zlib
    libvorbis
  ];

  meta = {
    description = "Car racing game (does not come with the game data required to run)";
    homepage = "https://torcs.sourceforge.net/";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ pixel-87 ];
    platforms = lib.platforms.linux;
  };
})
+2 −0
Original line number Diff line number Diff line
@@ -12983,6 +12983,8 @@ with pkgs;

  tora = libsForQt5.callPackage ../development/tools/tora { };

  torcs-without-data = callPackage ../../pkgs/by-name/to/torcs/without-data.nix { };

  nitrokey-app = libsForQt5.callPackage ../tools/security/nitrokey-app { };

  nitrokey-app2 = python3Packages.callPackage ../tools/security/nitrokey-app2 { };