2018-10-19 22:36:50 +01:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, file, getopt
|
2018-11-17 17:08:07 +00:00
|
|
|
, gtk2, gdk_pixbuf, glib, libGL, libGLU, nss, nspr, udev, tbb
|
2016-05-26 15:45:45 +01:00
|
|
|
, alsaLib, GConf, cups, libcap, fontconfig, freetype, pango
|
|
|
|
, cairo, dbus, expat, zlib, libpng12, nodejs, gnutar, gcc, gcc_32bit
|
|
|
|
, libX11, libXcursor, libXdamage, libXfixes, libXrender, libXi
|
2018-10-19 22:36:50 +01:00
|
|
|
, libXcomposite, libXext, libXrandr, libXtst, libSM, libICE, libxcb, chromium
|
2015-10-18 10:48:19 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2016-05-26 15:45:45 +01:00
|
|
|
libPath64 = lib.makeLibraryPath [
|
2018-11-17 17:08:07 +00:00
|
|
|
gcc.cc gtk2 gdk_pixbuf glib libGL libGLU nss nspr
|
2016-05-26 15:45:45 +01:00
|
|
|
alsaLib GConf cups libcap fontconfig freetype pango
|
2018-10-19 22:36:50 +01:00
|
|
|
cairo dbus expat zlib libpng12 udev tbb
|
2016-05-26 15:45:45 +01:00
|
|
|
libX11 libXcursor libXdamage libXfixes libXrender libXi
|
|
|
|
libXcomposite libXext libXrandr libXtst libSM libICE libxcb
|
2015-10-18 10:48:19 +01:00
|
|
|
];
|
2016-05-26 15:45:45 +01:00
|
|
|
libPath32 = lib.makeLibraryPath [ gcc_32bit.cc ];
|
|
|
|
binPath = lib.makeBinPath [ nodejs gnutar ];
|
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
ver = "2017.4.10";
|
2016-05-26 15:45:45 +01:00
|
|
|
build = "f1";
|
|
|
|
|
2015-10-18 10:48:19 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "unity-editor-${version}";
|
2017-04-12 14:51:42 +01:00
|
|
|
version = "${ver}x${build}";
|
2015-10-18 10:48:19 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2018-10-19 22:36:50 +01:00
|
|
|
url = "https://beta.unity3d.com/download/14396d76537e/LinuxEditorInstaller/Unity.tar.xz";
|
|
|
|
sha256 = "e1b4fe41c0ff793f7a9146c49a8eca8c71d30abdfa3e81922bd69699810b3f67";
|
2015-10-18 10:48:19 +01:00
|
|
|
};
|
|
|
|
|
2016-05-26 15:45:45 +01:00
|
|
|
nosuidLib = ./unity-nosuid.c;
|
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper file getopt ];
|
2016-05-26 15:45:45 +01:00
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
outputs = [ "out" ];
|
2015-10-18 10:48:19 +01:00
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
sourceRoot = ".";
|
2015-10-18 10:48:19 +01:00
|
|
|
|
2016-05-26 15:45:45 +01:00
|
|
|
buildPhase = ''
|
|
|
|
cd Editor
|
|
|
|
|
|
|
|
$CC -fPIC -shared -o libunity-nosuid.so $nosuidLib -ldl
|
|
|
|
strip libunity-nosuid.so
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
'';
|
|
|
|
|
2015-10-18 10:48:19 +01:00
|
|
|
installPhase = ''
|
2016-05-26 15:45:45 +01:00
|
|
|
unitydir="$out/opt/Unity/Editor"
|
2015-10-18 10:48:19 +01:00
|
|
|
mkdir -p $unitydir
|
2016-05-26 15:45:45 +01:00
|
|
|
mv Editor/* $unitydir
|
2017-01-29 10:11:01 +00:00
|
|
|
ln -sf /run/wrappers/bin/${chromium.sandboxExecutableName} $unitydir/chrome-sandbox
|
2015-10-18 10:48:19 +01:00
|
|
|
|
2016-05-26 15:45:45 +01:00
|
|
|
mkdir -p $out/bin
|
|
|
|
makeWrapper $unitydir/Unity $out/bin/unity-editor \
|
|
|
|
--prefix LD_PRELOAD : "$unitydir/libunity-nosuid.so" \
|
|
|
|
--prefix PATH : "${binPath}"
|
2015-10-18 10:48:19 +01:00
|
|
|
'';
|
|
|
|
|
2017-05-26 14:20:45 +01:00
|
|
|
preFixup = ''
|
|
|
|
patchFile() {
|
|
|
|
ftype="$(file -b "$1")"
|
|
|
|
if [[ "$ftype" =~ LSB\ .*dynamically\ linked ]]; then
|
|
|
|
if [[ "$ftype" =~ 32-bit ]]; then
|
|
|
|
rpath="${libPath32}"
|
|
|
|
intp="$(cat $NIX_CC/nix-support/dynamic-linker-m32)"
|
|
|
|
else
|
|
|
|
rpath="${libPath64}"
|
|
|
|
intp="$(cat $NIX_CC/nix-support/dynamic-linker)"
|
|
|
|
fi
|
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
# Save origin-relative parts of rpath.
|
|
|
|
originRpath="$(patchelf --print-rpath "$1" | sed "s/:/\n/g" | grep "^\$ORIGIN" | paste -sd ":" - || echo "")"
|
|
|
|
rpath="$originRpath:$rpath"
|
|
|
|
|
|
|
|
patchelf --set-rpath "$rpath" "$1"
|
|
|
|
patchelf --set-interpreter "$intp" "$1" 2> /dev/null || true
|
2017-05-26 14:20:45 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-10-19 22:36:50 +01:00
|
|
|
upm_linux=$unitydir/Data/Resources/Upm/upm-linux
|
|
|
|
|
|
|
|
orig_size=$(stat --printf=%s $upm_linux)
|
|
|
|
|
2017-05-26 14:20:45 +01:00
|
|
|
# Exclude PlaybackEngines to build something that can be run on FHS-compliant Linuxes
|
|
|
|
find $unitydir -name PlaybackEngines -prune -o -type f -print | while read path; do
|
|
|
|
patchFile "$path"
|
|
|
|
done
|
2018-10-19 22:36:50 +01:00
|
|
|
|
|
|
|
new_size=$(stat --printf=%s $upm_linux)
|
|
|
|
|
|
|
|
###### zeit-pkg fixing starts here.
|
|
|
|
# we're replacing plaintext js code that looks like
|
|
|
|
# PAYLOAD_POSITION = '1234 ' | 0
|
|
|
|
# [...]
|
|
|
|
# PRELUDE_POSITION = '1234 ' | 0
|
|
|
|
# ^-----20-chars-----^^------22-chars------^
|
|
|
|
# ^-- grep points here
|
|
|
|
#
|
|
|
|
# var_* are as described above
|
|
|
|
# shift_by seems to be safe so long as all patchelf adjustments occur
|
|
|
|
# before any locations pointed to by hardcoded offsets
|
|
|
|
|
|
|
|
var_skip=20
|
|
|
|
var_select=22
|
|
|
|
shift_by=$(expr $new_size - $orig_size)
|
|
|
|
|
|
|
|
function fix_offset {
|
|
|
|
# $1 = name of variable to adjust
|
|
|
|
location=$(grep -obUam1 "$1" $upm_linux | cut -d: -f1)
|
|
|
|
location=$(expr $location + $var_skip)
|
|
|
|
value=$(dd if=$upm_linux iflag=count_bytes,skip_bytes skip=$location \
|
|
|
|
bs=1 count=$var_select status=none)
|
|
|
|
value=$(expr $shift_by + $value)
|
|
|
|
echo -n $value | dd of=$upm_linux bs=1 seek=$location conv=notrunc
|
|
|
|
}
|
|
|
|
|
|
|
|
fix_offset PAYLOAD_POSITION
|
|
|
|
fix_offset PRELUDE_POSITION
|
2017-05-26 14:20:45 +01:00
|
|
|
'';
|
|
|
|
|
2015-10-18 10:48:19 +01:00
|
|
|
dontStrip = true;
|
2017-04-12 14:51:42 +01:00
|
|
|
dontPatchELF = true;
|
2015-10-18 10:48:19 +01:00
|
|
|
|
2016-05-26 15:45:45 +01:00
|
|
|
meta = with stdenv.lib; {
|
2015-10-18 10:48:19 +01:00
|
|
|
homepage = https://unity3d.com/;
|
|
|
|
description = "Game development tool";
|
|
|
|
longDescription = ''
|
|
|
|
Popular development platform for creating 2D and 3D multiplatform games
|
|
|
|
and interactive experiences.
|
|
|
|
'';
|
2016-05-26 15:45:45 +01:00
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
2019-04-11 15:11:21 +01:00
|
|
|
maintainers = with maintainers; [ jb55 tesq0 ];
|
2015-10-18 10:48:19 +01:00
|
|
|
};
|
|
|
|
}
|