about summary refs log tree commit diff
path: root/pkgs/misc/emulators/higan/builder.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/misc/emulators/higan/builder.sh')
-rw-r--r--pkgs/misc/emulators/higan/builder.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkgs/misc/emulators/higan/builder.sh b/pkgs/misc/emulators/higan/builder.sh
index 144c23d39de5..a99ccf26dbbd 100644
--- a/pkgs/misc/emulators/higan/builder.sh
+++ b/pkgs/misc/emulators/higan/builder.sh
@@ -18,3 +18,25 @@ install -m 644 ananke/libananke.so $out/lib/libananke.so.1
 (cd $out/lib && ln -s libananke.so.1 libananke.so)
 oldRPath=$(patchelf --print-rpath $out/bin/higan)
 patchelf --set-rpath $oldRPath:$out/lib $out/bin/higan
+
+# A dirty workaround, suggested by @cpages:
+# we create a wrapper script to set up
+# $HOME local configuration before higan runs
+
+mv $out/bin/higan $out/bin/.higan-wrapped
+cat <<EOF > $out/bin/higan 
+
+#!/bin/bash
+if [ ! -e \$HOME/.config/higan/.was_configured ]
+then
+    cp --update --recursive $out/share/higan \$HOME/.config
+    chmod --recursive u+w \$HOME/.config/higan
+    touch \$HOME/.config/higan/.was_configured
+fi
+# LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$out/lib
+$out/bin/.higan-wrapped "\$@"
+
+EOF
+
+patchShebangs $out/bin/higan
+chmod +x $out/bin/higan