From 73fa69908c3791a0328f13012075a8bf563329eb Mon Sep 17 00:00:00 2001 From: langsjo <104687438+langsjo@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:32:55 +0200 Subject: [PATCH] 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. --- pkgs/by-name/to/torcs/package.nix | 109 +++++++++---------------- pkgs/by-name/to/torcs/without-data.nix | 74 +++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 114 insertions(+), 71 deletions(-) create mode 100644 pkgs/by-name/to/torcs/without-data.nix diff --git a/pkgs/by-name/to/torcs/package.nix b/pkgs/by-name/to/torcs/package.nix index 7912a04c0d88..e35e35932e0b 100644 --- a/pkgs/by-name/to/torcs/package.nix +++ b/pkgs/by-name/to/torcs/package.nix @@ -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 = [ ]; }; -}) +} diff --git a/pkgs/by-name/to/torcs/without-data.nix b/pkgs/by-name/to/torcs/without-data.nix new file mode 100644 index 000000000000..05634a1b7d71 --- /dev/null +++ b/pkgs/by-name/to/torcs/without-data.nix @@ -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; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 968fec3c04b1..1a94717248bc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };