rott: refactor

This commit is contained in:
Marcin Serwin 2025-03-02 16:19:15 +01:00
parent c8def8c218
commit fa72edbde7
No known key found for this signature in database
GPG Key ID: DACFAC4EA0B194E0

View File

@ -2,33 +2,19 @@
stdenv, stdenv,
lib, lib,
fetchurl, fetchurl,
writeShellScript,
SDL_compat, SDL_compat,
SDL_mixer, SDL_mixer,
makeDesktopItem, makeDesktopItem,
copyDesktopItems, copyDesktopItems,
runtimeShell,
buildShareware ? false, buildShareware ? false,
}: }:
stdenv.mkDerivation (finalAttrs: {
let
# Allow the game to be launched from a user's PATH and load the game data from the user's home directory.
launcher = writeShellScript "rott" ''
set -eEuo pipefail
dir=$HOME/.rott/data
test -e $dir || mkdir -p $dir
cd $dir
exec @out@/libexec/rott "$@"
'';
in
stdenv.mkDerivation rec {
pname = "rott"; pname = "rott";
version = "1.1.2"; version = "1.1.2";
src = fetchurl { src = fetchurl {
url = "https://icculus.org/rott/releases/${pname}-${version}.tar.gz"; url = "https://icculus.org/rott/releases/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
sha256 = "1zr7v5dv2iqx40gzxbg8mhac7fxz3kqf28y6ysxv1xhjqgl1c98h"; hash = "sha256-ECUW6MMS9rC79sYj4fAcv7vDFKzorf4fIB1HsVvZJ/8=";
}; };
nativeBuildInputs = [ copyDesktopItems ]; nativeBuildInputs = [ copyDesktopItems ];
@ -38,7 +24,9 @@ stdenv.mkDerivation rec {
SDL_mixer SDL_mixer
]; ];
sourceRoot = "rott-${version}/rott"; enableParallelBuilding = true;
sourceRoot = "rott-${finalAttrs.version}/rott";
makeFlags = [ makeFlags = [
"SHAREWARE=${if buildShareware then "1" else "0"}" "SHAREWARE=${if buildShareware then "1" else "0"}"
@ -47,9 +35,7 @@ stdenv.mkDerivation rec {
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -Dm555 -t $out/libexec rott install -Dm755 -t $out/bin rott
install -Dm555 ${launcher} $out/bin/${launcher.name}
substituteInPlace $out/bin/rott --subst-var out
runHook postInstall runHook postInstall
''; '';
@ -63,12 +49,12 @@ stdenv.mkDerivation rec {
}) })
]; ];
meta = with lib; { meta = {
description = "SDL port of Rise of the Triad"; description = "SDL port of Rise of the Triad";
mainProgram = "rott"; mainProgram = "rott";
homepage = "https://icculus.org/rott/"; homepage = "https://icculus.org/rott/";
license = licenses.gpl2Plus; license = lib.licenses.gpl2Plus;
maintainers = with maintainers; [ sander ]; maintainers = with lib.maintainers; [ sander ];
platforms = platforms.all; platforms = lib.platforms.all;
}; };
} })