Merge pull request #15793 from abbradar/unity3d-pkg

Unity3D package

+206
+1
nixos/modules/module-list.nix
··· 79 79 ./programs/ssh.nix 80 80 ./programs/ssmtp.nix 81 81 ./programs/tmux.nix 82 + ./programs/unity3d.nix 82 83 ./programs/venus.nix 83 84 ./programs/wvdial.nix 84 85 ./programs/xfs_quota.nix
+25
nixos/modules/programs/unity3d.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let cfg = config.programs.unity3d; 6 + in { 7 + 8 + options = { 9 + programs.unity3d.enable = mkEnableOption "Unity3D, a game development tool"; 10 + }; 11 + 12 + config = mkIf cfg.enable { 13 + security.setuidOwners = [{ 14 + program = "unity-chrome-sandbox"; 15 + source = "${pkgs.unity3d.sandbox}/bin/unity-chrome-sandbox"; 16 + owner = "root"; 17 + #group = "root"; 18 + setuid = true; 19 + #setgid = true; 20 + }]; 21 + 22 + environment.systemPackages = [ pkgs.unity3d ]; 23 + }; 24 + 25 + }
+142
pkgs/development/tools/unity3d/default.nix
··· 1 + { stdenv, lib, fetchurl, makeWrapper, fakeroot, file, getopt 2 + , gtk2, gdk_pixbuf, glib, mesa_glu, postgresql, nss, nspr 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 8 + }: 9 + 10 + let 11 + libPath64 = lib.makeLibraryPath [ 12 + gcc.cc gtk2 gdk_pixbuf glib mesa_glu postgresql nss nspr 13 + alsaLib GConf cups libcap fontconfig freetype pango 14 + cairo dbus expat zlib libpng12 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 gtk-sharp.gtk 23 + ]; 24 + developDotnetPath = lib.concatStringsSep ":" [ 25 + gnome-sharp gtk-sharp 26 + ]; 27 + 28 + ver = "5.3.5"; 29 + build = "f1"; 30 + date = "20160525"; 31 + pkgVer = "${ver}${build}"; 32 + fullVer = "${pkgVer}+${date}"; 33 + 34 + in stdenv.mkDerivation rec { 35 + name = "unity-editor-${version}"; 36 + version = pkgVer; 37 + 38 + src = fetchurl { 39 + url = "http://download.unity3d.com/download_unity/linux/unity-editor-installer-${fullVer}.sh"; 40 + sha256 = "0lmc65175fdvbyn3565pjlg6cc4l5i58fj7bxzi5cqykkbzv5wdm"; 41 + }; 42 + 43 + nosuidLib = ./unity-nosuid.c; 44 + 45 + nativeBuildInputs = [ makeWrapper fakeroot file getopt ]; 46 + 47 + outputs = [ "out" "monodevelop" "sandbox" ]; 48 + 49 + unpackPhase = '' 50 + echo -e 'q\ny' | fakeroot sh $src 51 + sourceRoot="unity-editor-${pkgVer}" 52 + ''; 53 + 54 + buildPhase = '' 55 + patchFile() { 56 + ftype="$(file -b "$1")" 57 + if [[ "$ftype" =~ LSB\ .*dynamically\ linked ]]; then 58 + if [[ "$ftype" =~ 32-bit ]]; then 59 + rpath="${libPath32}" 60 + intp="$(cat $NIX_CC/nix-support/dynamic-linker-m32)" 61 + else 62 + rpath="${libPath64}" 63 + intp="$(cat $NIX_CC/nix-support/dynamic-linker)" 64 + fi 65 + 66 + rpath="$(patchelf --print-rpath "$1"):$rpath" 67 + if [[ "$ftype" =~ LSB\ shared ]]; then 68 + patchelf \ 69 + --set-rpath "$rpath" \ 70 + "$1" 71 + elif [[ "$ftype" =~ LSB\ executable ]]; then 72 + patchelf \ 73 + --set-rpath "$rpath" \ 74 + --interpreter "$intp" \ 75 + "$1" 76 + fi 77 + fi 78 + } 79 + 80 + cd Editor 81 + 82 + $CC -fPIC -shared -o libunity-nosuid.so $nosuidLib -ldl 83 + strip libunity-nosuid.so 84 + 85 + # Exclude PlaybackEngines to build something that can be run on FHS-compliant Linuxes 86 + find . -name PlaybackEngines -prune -o -executable -type f -print | while read path; do 87 + patchFile "$path" 88 + done 89 + 90 + cd .. 91 + ''; 92 + 93 + installPhase = '' 94 + install -Dm755 Editor/chrome-sandbox $sandbox/bin/unity-chrome-sandbox 95 + 96 + unitydir="$out/opt/Unity/Editor" 97 + mkdir -p $unitydir 98 + mv Editor/* $unitydir 99 + ln -sf /var/setuid-wrappers/unity-chrome-sandbox $unitydir/chrome-sandbox 100 + 101 + mkdir -p $out/share/applications 102 + sed "/^Exec=/c\Exec=$out/bin/unity-editor" \ 103 + < unity-editor.desktop \ 104 + > $out/share/applications/unity-editor.desktop 105 + 106 + install -D unity-editor-icon.png $out/share/icons/hicolor/256x256/apps/unity-editor-icon.png 107 + 108 + mkdir -p $out/bin 109 + makeWrapper $unitydir/Unity $out/bin/unity-editor \ 110 + --prefix LD_PRELOAD : "$unitydir/libunity-nosuid.so" \ 111 + --prefix PATH : "${binPath}" 112 + 113 + developdir="$monodevelop/opt/Unity/MonoDevelop" 114 + mkdir -p $developdir 115 + mv MonoDevelop/* $developdir 116 + 117 + mkdir -p $monodevelop/share/applications 118 + sed "/^Exec=/c\Exec=$monodevelop/bin/unity-monodevelop" \ 119 + < unity-monodevelop.desktop \ 120 + > $monodevelop/share/applications/unity-monodevelop.desktop 121 + 122 + mkdir -p $monodevelop/bin 123 + makeWrapper $developdir/bin/monodevelop $monodevelop/bin/unity-monodevelop \ 124 + --prefix PATH : "${developBinPath}" \ 125 + --prefix LD_LIBRARY_PATH : "${developLibPath}" \ 126 + --prefix MONO_GAC_PREFIX : "${developDotnetPath}" 127 + ''; 128 + 129 + dontStrip = true; 130 + 131 + meta = with stdenv.lib; { 132 + homepage = https://unity3d.com/; 133 + description = "Game development tool"; 134 + longDescription = '' 135 + Popular development platform for creating 2D and 3D multiplatform games 136 + and interactive experiences. 137 + ''; 138 + license = licenses.unfree; 139 + platforms = [ "x86_64-linux" ]; 140 + maintainers = with maintainers; [ jb55 ]; 141 + }; 142 + }
+32
pkgs/development/tools/unity3d/unity-nosuid.c
··· 1 + #define _GNU_SOURCE 2 + 3 + #include <stdio.h> 4 + #include <string.h> 5 + #include <sys/stat.h> 6 + #include <unistd.h> 7 + #include <dlfcn.h> 8 + 9 + static const char sandbox_path[] = "/chrome-sandbox"; 10 + 11 + int __xstat(int ver, const char* path, struct stat* stat_buf) { 12 + static int (*original_xstat)(int, const char*, struct stat*) = NULL; 13 + if (original_xstat == NULL) { 14 + int (*fun)(int, const char*, struct stat*) = dlsym(RTLD_NEXT, "__xstat"); 15 + if (fun == NULL) { 16 + return -1; 17 + }; 18 + original_xstat = fun; 19 + }; 20 + 21 + int res = (*original_xstat)(ver, path, stat_buf); 22 + if (res == 0) { 23 + char* pos = strstr(path, sandbox_path); 24 + if (pos != NULL && *(pos + sizeof(sandbox_path) - 1) == '\0') { 25 + printf("Lying about chrome-sandbox access rights...\n"); 26 + stat_buf->st_uid = 0; 27 + stat_buf->st_gid = 0; 28 + stat_buf->st_mode = 0104755; 29 + }; 30 + } 31 + return res; 32 + }
+6
pkgs/top-level/all-packages.nix
··· 16779 16779 16780 16780 ums = callPackage ../servers/ums { }; 16781 16781 16782 + unity3d = callPackage ../development/tools/unity3d { 16783 + stdenv = stdenv_32bit; 16784 + gcc_32bit = pkgsi686Linux.gcc; 16785 + inherit (gnome2) GConf libgnomeui gnome_vfs; 16786 + }; 16787 + 16782 16788 urbit = callPackage ../misc/urbit { }; 16783 16789 16784 16790 utf8proc = callPackage ../development/libraries/utf8proc { };