Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 144 lines 4.6 kB view raw
1{ stdenv, lib, fetchurl, makeWrapper, fakeroot, file, getopt 2, gtk2, gdk_pixbuf, glib, libGLU, postgresql, nss, nspr, udev 3, alsaLib, GConf, cups, libcap, fontconfig, freetype, pango 4, cairo, dbus, expat, zlib, libpng12, nodejs, gnutar, gcc, gcc_32bit 5, libX11, libXcursor, libXdamage, libXfixes, libXrender, libXi 6, libXcomposite, libXext, libXrandr, libXtst, libSM, libICE, libxcb 7, mono, libgnomeui, gnome_vfs, gnome-sharp, gtk-sharp-2_0, chromium 8}: 9 10let 11 libPath64 = lib.makeLibraryPath [ 12 gcc.cc gtk2 gdk_pixbuf glib libGLU postgresql nss nspr 13 alsaLib GConf cups libcap fontconfig freetype pango 14 cairo dbus expat zlib libpng12 udev 15 libX11 libXcursor libXdamage libXfixes libXrender libXi 16 libXcomposite libXext libXrandr libXtst libSM libICE libxcb 17 ]; 18 libPath32 = lib.makeLibraryPath [ gcc_32bit.cc ]; 19 binPath = lib.makeBinPath [ nodejs gnutar ]; 20 developBinPath = lib.makeBinPath [ mono ]; 21 developLibPath = lib.makeLibraryPath [ 22 glib libgnomeui gnome_vfs gnome-sharp gtk-sharp-2_0 gtk-sharp-2_0.gtk 23 ]; 24 developDotnetPath = lib.concatStringsSep ":" [ 25 gnome-sharp gtk-sharp-2_0 26 ]; 27 28 ver = "5.6.1"; 29 build = "f1"; 30 31in stdenv.mkDerivation rec { 32 name = "unity-editor-${version}"; 33 version = "${ver}x${build}"; 34 35 src = fetchurl { 36 url = "http://beta.unity3d.com/download/6a86e542cf5c/unity-editor-installer-${version}Linux.sh"; 37 sha256 = "10z4h94c9h967gx4b3gwb268zn7bnrb7ylnqnmnqhx6byac7cf4m"; 38 }; 39 40 nosuidLib = ./unity-nosuid.c; 41 42 nativeBuildInputs = [ makeWrapper fakeroot file getopt ]; 43 44 outputs = [ "out" "monodevelop" ]; 45 46 sourceRoot = "unity-editor-${version}Linux"; 47 48 unpackPhase = '' 49 echo -e 'q\ny' | fakeroot sh $src 50 ''; 51 52 buildPhase = '' 53 54 cd Editor 55 56 $CC -fPIC -shared -o libunity-nosuid.so $nosuidLib -ldl 57 strip libunity-nosuid.so 58 59 cd .. 60 ''; 61 62 installPhase = '' 63 unitydir="$out/opt/Unity/Editor" 64 mkdir -p $unitydir 65 mv Editor/* $unitydir 66 ln -sf /run/wrappers/bin/${chromium.sandboxExecutableName} $unitydir/chrome-sandbox 67 68 mkdir -p $out/share/applications 69 sed "/^Exec=/c\Exec=$out/bin/unity-editor" \ 70 < unity-editor.desktop \ 71 > $out/share/applications/unity-editor.desktop 72 73 install -D unity-editor-icon.png $out/share/icons/hicolor/256x256/apps/unity-editor-icon.png 74 75 mkdir -p $out/bin 76 makeWrapper $unitydir/Unity $out/bin/unity-editor \ 77 --prefix LD_PRELOAD : "$unitydir/libunity-nosuid.so" \ 78 --prefix PATH : "${binPath}" 79 80 developdir="$monodevelop/opt/Unity/MonoDevelop" 81 mkdir -p $developdir 82 mv MonoDevelop/* $developdir 83 84 mkdir -p $monodevelop/share/applications 85 sed "/^Exec=/c\Exec=$monodevelop/bin/unity-monodevelop" \ 86 < unity-monodevelop.desktop \ 87 > $monodevelop/share/applications/unity-monodevelop.desktop 88 89 mkdir -p $monodevelop/bin 90 makeWrapper $developdir/bin/monodevelop $monodevelop/bin/unity-monodevelop \ 91 --prefix PATH : "${developBinPath}" \ 92 --prefix LD_LIBRARY_PATH : "${developLibPath}" \ 93 --prefix MONO_GAC_PREFIX : "${developDotnetPath}" 94 ''; 95 96 preFixup = '' 97 patchFile() { 98 ftype="$(file -b "$1")" 99 if [[ "$ftype" =~ LSB\ .*dynamically\ linked ]]; then 100 if [[ "$ftype" =~ 32-bit ]]; then 101 rpath="${libPath32}" 102 intp="$(cat $NIX_CC/nix-support/dynamic-linker-m32)" 103 else 104 rpath="${libPath64}" 105 intp="$(cat $NIX_CC/nix-support/dynamic-linker)" 106 fi 107 108 oldRpath="$(patchelf --print-rpath "$1")" 109 # Always search at least for libraries in origin directory. 110 rpath="''${oldRpath:-\$ORIGIN}:$rpath" 111 if [[ "$ftype" =~ LSB\ shared ]]; then 112 patchelf \ 113 --set-rpath "$rpath" \ 114 "$1" 115 elif [[ "$ftype" =~ LSB\ executable ]]; then 116 patchelf \ 117 --set-rpath "$rpath" \ 118 --interpreter "$intp" \ 119 "$1" 120 fi 121 fi 122 } 123 124 # Exclude PlaybackEngines to build something that can be run on FHS-compliant Linuxes 125 find $unitydir -name PlaybackEngines -prune -o -type f -print | while read path; do 126 patchFile "$path" 127 done 128 ''; 129 130 dontStrip = true; 131 dontPatchELF = true; 132 133 meta = with stdenv.lib; { 134 homepage = https://unity3d.com/; 135 description = "Game development tool"; 136 longDescription = '' 137 Popular development platform for creating 2D and 3D multiplatform games 138 and interactive experiences. 139 ''; 140 license = licenses.unfree; 141 platforms = [ "x86_64-linux" ]; 142 maintainers = with maintainers; [ jb55 ]; 143 }; 144}