about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-12-31 01:53:46 +0100
committerGitHub <noreply@github.com>2020-12-31 01:53:46 +0100
commita8f2b9f4d900836b2e64babdbc191247f93f008f (patch)
tree788df28fa06c0e410fdc7f684f72f5c46772d692 /pkgs/games
parent3658b4009fbf7b9e1c8774bb36cbcc565a3ef568 (diff)
parent61b94d70722d3e6deb62bc0af8474d69d2070b89 (diff)
downloadnixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar.gz
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar.bz2
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar.lz
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar.xz
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.tar.zst
nixlib-a8f2b9f4d900836b2e64babdbc191247f93f008f.zip
Merge pull request #67643 from MetaDark/clonehero
clonehero: init at 0.23.2.2
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/clonehero/default.nix73
-rw-r--r--pkgs/games/clonehero/fhs-wrapper.nix39
-rw-r--r--pkgs/games/clonehero/xdg-wrapper.nix21
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} "$@"
+''