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.
This commit is contained in:
langsjo
2026-02-06 00:15:47 +02:00
parent 60dbab5d04
commit 73fa69908c
3 changed files with 114 additions and 71 deletions
+38 -71
View File
@@ -1,84 +1,51 @@
{
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,
}:
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
;
stdenv.mkDerivation (finalAttrs: {
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
'';
meta.hydraPlatforms = [ ];
});
in
symlinkJoin {
pname = "torcs";
version = "1.3.8";
inherit (torcs-without-data)
version
;
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";
})
paths = [
torcs-without-data
torcs-data
];
postInstall = ''
install -D -m644 Ticon.png $out/share/pixmaps/torcs.png
install -D -m644 torcs.desktop $out/share/applications/torcs.desktop
postBuild = ''
cp --remove-destination $(realpath $out/bin/torcs) $out/bin/torcs
substituteInPlace $out/bin/torcs \
--replace-fail "${torcs-without-data}" "$out"
'';
postPatch = ''
sed -i -e s,/bin/bash,`type -P bash`, src/linux/torcs.in
'';
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
libGLU
libglut
libX11
plib
openal
freealut
libXrandr
xorgproto
libXext
libsm
libice
libXi
libXt
libXrender
libXxf86vm
libpng
zlib
libvorbis
];
installTargets = "install datainstall";
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
View File
@@ -0,0 +1,74 @@
{
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
View File
@@ -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 { };