Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Last active January 19, 2020 01:49
Show Gist options
  • Save Profpatsch/899ea8f9afe7d1912ac83a199a4cfea7 to your computer and use it in GitHub Desktop.
Save Profpatsch/899ea8f9afe7d1912ac83a199a4cfea7 to your computer and use it in GitHub Desktop.
Pillars of Eternity on nixos
#!/usr/bin/env bash
read -r -d '' NIXEXPR <<EOF
with import <nixpkgs> {};
runCommand "foo" {} ''
mkdir \$out
echo "\${lib.makeLibraryPath [ mesa xorg.libX11 xorg.libXext xorg.libXcursor xorg.libXrandr pkgsi686Linux.alsaPlugins libpulseaudio stdenv.cc.cc.lib ]}" > \$out/path
cp \$NIX_CC/nix-support/dynamic-linker \$out/ld
''
EOF
f=$(nix-build -E "$NIXEXPR")
if [[ -z "$f" ]]; then
echo "could not build nixexpr"
exit 1
fi
exe=./game/PillarsOfEternity
patchelfPath="$(nix-build -A patchelf '<nixpkgs>')"
patchelf="$patchelfPath/bin/patchelf"
if [[ -z "$patchelfPath" ]]; then
echo "could not build patchelf"
exit 1
fi
oldinterpr=$($patchelf --print-interpreter "$exe")
newinterpr=$(cat "$f/ld")
if [[ "$oldinterpr" != "$newinterpr" ]]; then
echo "patching $exe from $oldinterpr to $newinterpr"
$patchelf --set-interpreter "$newinterpr" "$exe"
fi
LPATH=$(cat "$f/path")
env LD_LIBRARY_PATH=$LPATH bash start.sh
@sunnystormy
Copy link

sunnystormy commented Jan 8, 2017

Will this technically work with any Unity-produced Linux executable? (Changing the executable name on line 18, of course)

@dpc
Copy link

dpc commented Dec 8, 2019

$NIX_CC seems empty, and I don't know why

@Profpatsch
Copy link
Author

@dpc replace runCommand with runCommandCC then it should work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment