about summary refs log tree commit diff
path: root/pkgs/games/clonehero/xdg-wrapper.nix
blob: 2890e469db050dff9d1e82c1e209c11679bbd344 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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} "$@"
''