diff options
author | MetaDark <kira.bruneau@gmail.com> | 2019-08-23 08:12:52 -0400 |
---|---|---|
committer | Kira Bruneau <kira.bruneau@gmail.com> | 2020-11-25 13:32:53 -0500 |
commit | 61b94d70722d3e6deb62bc0af8474d69d2070b89 (patch) | |
tree | 97b3d55e5a8fd303a33f96fa9ce93648eaf0fbc0 /pkgs/games | |
parent | 661712230656a31fdcb4b0e8f4406a2c41197929 (diff) | |
download | nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar.gz nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar.bz2 nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar.lz nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar.xz nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.tar.zst nixlib-61b94d70722d3e6deb62bc0af8474d69d2070b89.zip |
clonehero: init at 0.23.2.2
Diffstat (limited to 'pkgs/games')
-rw-r--r-- | pkgs/games/clonehero/default.nix | 73 | ||||
-rw-r--r-- | pkgs/games/clonehero/fhs-wrapper.nix | 39 | ||||
-rw-r--r-- | pkgs/games/clonehero/xdg-wrapper.nix | 21 |
3 files changed, 133 insertions, 0 deletions
diff --git a/pkgs/games/clonehero/default.nix b/pkgs/games/clonehero/default.nix new file mode 100644 index 000000000000..504e4811432b --- /dev/null +++ b/pkgs/games/clonehero/default.nix @@ -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" ]; + }; +} diff --git a/pkgs/games/clonehero/fhs-wrapper.nix b/pkgs/games/clonehero/fhs-wrapper.nix new file mode 100644 index 000000000000..97758b2c1fab --- /dev/null +++ b/pkgs/games/clonehero/fhs-wrapper.nix @@ -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 { }; +} diff --git a/pkgs/games/clonehero/xdg-wrapper.nix b/pkgs/games/clonehero/xdg-wrapper.nix new file mode 100644 index 000000000000..2890e469db05 --- /dev/null +++ b/pkgs/games/clonehero/xdg-wrapper.nix @@ -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} "$@" +'' |