clonehero: init at 0.23.2.2

This commit is contained in:
MetaDark 2019-08-23 08:12:52 -04:00 committed by Kira Bruneau
parent 6617122306
commit 61b94d7072
4 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,73 @@
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, alsaLib
, gtk2
, libXrandr
, libXScrnSaver
, udev
, zlib
}:
let
name = "clonehero";
in
stdenv.mkDerivation rec {
pname = "${name}-unwrapped";
version = "0.23.2.2";
src = fetchurl {
url = "http://dl.clonehero.net/${name}-v${lib.removePrefix "0" version}/${name}-linux.tar.gz";
sha256 = "0k9jcnd55yhr42gj8cmysd18yldp4k3cpk4z884p2ww03fyfq7mi";
};
outputs = [ "out" "doc" ];
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [
# Load-time libraries (loaded from DT_NEEDED section in ELF binary)
gtk2
stdenv.cc.cc.lib
zlib
# Run-time libraries (loaded with dlopen)
alsaLib # ALSA sound
libXrandr # X11 resolution detection
libXScrnSaver # X11 screensaver prevention
udev # udev input drivers
];
installPhase = ''
mkdir -p "$out/bin" "$out/share"
install -Dm755 ${name} "$out/bin"
cp -r clonehero_Data "$out/share"
mkdir -p "$doc/share/${name}"
cp README.txt "$doc/share/${name}"
'';
# Patch required run-time libraries as load-time libraries
#
# Libraries found with:
# > strings clonehero | grep '\.so'
# and
# > strace clonehero 2>&1 | grep '\.so'
postFixup = ''
patchelf \
--add-needed libasound.so.2 \
--add-needed libudev.so.1 \
--add-needed libXrandr.so.2 \
--add-needed libXss.so.1 \
"$out/bin/${name}"
'';
meta = with lib; {
description = "Clone of Guitar Hero and Rockband-style games";
homepage = "https://clonehero.net";
license = licenses.unfree;
maintainers = with maintainers; [ metadark ];
platforms = [ "x86_64-linux" ];
};
}

View File

@ -0,0 +1,39 @@
{ clonehero-unwrapped
, makeDesktopItem
, buildFHSUserEnv
, liberation_ttf
, callPackage
}:
let
name = "clonehero";
desktopName = "Clone Hero";
desktopItem = makeDesktopItem {
inherit name desktopName;
comment = clonehero-unwrapped.meta.description;
exec = name;
icon = name;
categories = "Game;";
};
in
buildFHSUserEnv {
inherit name;
inherit (clonehero-unwrapped) meta;
# Clone Hero has /usr/share/fonts hard-coded in its binary for looking up fonts.
# This workaround is necessary for rendering text on the keybinding screen (and possibly elsewhere)
# If a better solution is found, the FHS environment can be removed.
extraBuildCommands = ''
chmod +w usr/share
mkdir -p usr/share/fonts/truetype
ln -s ${liberation_ttf}/share/fonts/truetype/* usr/share/fonts/truetype
'';
extraInstallCommands = ''
mkdir -p "$out/share/applications" "$out/share/pixmaps"
cp ${desktopItem}/share/applications/* "$out/share/applications"
ln -s ${clonehero-unwrapped}/share/clonehero_Data/Resources/UnityPlayer.png "$out/share/pixmaps/${name}.png"
'';
runScript = callPackage ./xdg-wrapper.nix { };
}

View File

@ -0,0 +1,21 @@
{ stdenv, clonehero-unwrapped, writeScript }:
# Clone Hero doesn't have an installer, so it just stores configuration & data relative to the binary.
# This wrapper works around that limitation, storing game configuration & data in XDG_CONFIG_HOME.
let
name = "clonehero";
desktopName = "Clone Hero";
in
writeScript "${name}-xdg-wrapper-${clonehero-unwrapped.version}" ''
#!${stdenv.shell} -e
configDir="''${XDG_CONFIG_HOME:-$HOME/.config}/unity3d/srylain Inc_/${desktopName}"
mkdir -p "$configDir"
# Force link shipped clonehero_Data, unless directory already exists (to allow modding)
if [ ! -d "$configDir/clonehero_Data" ] || [ -L "$configDir/clonehero_Data" ]; then
ln -snf ${clonehero-unwrapped}/share/clonehero_Data "$configDir"
fi
# Fake argv[0] to emulate running in the config directory
exec -a "$configDir/${name}" ${clonehero-unwrapped}/bin/${name} "$@"
''

View File

@ -25245,6 +25245,10 @@ in
chocolateDoom = callPackage ../games/chocolate-doom { };
clonehero-unwrapped = pkgs.callPackage ../games/clonehero { };
clonehero = pkgs.callPackage ../games/clonehero/fhs-wrapper.nix { };
crispyDoom = callPackage ../games/crispy-doom { };
cri-o = callPackage ../applications/virtualization/cri-o/wrapper.nix { };