1{ lib
2, stdenv
3, fetchurl
4, dpkg
5, makeWrapper
6, buildFHSEnv
7, extraPkgs ? pkgs: [ ]
8, extraLibs ? pkgs: [ ]
9}:
10
11stdenv.mkDerivation rec {
12 pname = "unityhub";
13 version = "3.4.2";
14
15 src = fetchurl {
16 url = "https://hub-dist.unity3d.com/artifactory/hub-debian-prod-local/pool/main/u/unity/unityhub_amd64/unityhub-amd64-${version}.deb";
17 sha256 = "sha256-I1qtrD94IpMut0a6JUHErHaksoZ+z8/dDG8U68Y5zJE=";
18 };
19
20 nativeBuildInputs = [
21 dpkg
22 makeWrapper
23 ];
24
25 fhsEnv = buildFHSEnv {
26 name = "${pname}-fhs-env";
27 runScript = "";
28
29 targetPkgs = pkgs: with pkgs; [
30 xorg.libXrandr
31
32 # GTK filepicker
33 gsettings-desktop-schemas
34 hicolor-icon-theme
35
36 # Bug Reporter dependencies
37 fontconfig
38 freetype
39 lsb-release
40 ] ++ extraPkgs pkgs;
41
42 multiPkgs = pkgs: with pkgs; [
43 # Unity Hub ldd dependencies
44 cups
45 gtk3
46 expat
47 libxkbcommon
48 lttng-ust_2_12
49 krb5
50 alsa-lib
51 nss_latest
52 libdrm
53 mesa
54 nspr
55 atk
56 dbus
57 at-spi2-core
58 pango
59 xorg.libXcomposite
60 xorg.libXext
61 xorg.libXdamage
62 xorg.libXfixes
63 xorg.libxcb
64 xorg.libxshmfence
65 xorg.libXScrnSaver
66 xorg.libXtst
67
68 # Unity Hub additional dependencies
69 libva
70 openssl
71 cairo
72 xdg-utils
73 libnotify
74 libuuid
75 libsecret
76 udev
77 libappindicator
78 wayland
79 cpio
80 icu
81 libpulseaudio
82
83 # Editor dependencies
84 libglvnd # provides ligbl
85 xorg.libX11
86 xorg.libXcursor
87 glib
88 gdk-pixbuf
89 libxml2
90 zlib
91 clang
92 git # for git-based packages in unity package manager
93 ] ++ extraLibs pkgs;
94 };
95
96 unpackCmd = "dpkg -x $curSrc src";
97
98 dontConfigure = true;
99 dontBuild = true;
100
101 installPhase = ''
102 runHook preInstall
103
104 mkdir -p $out
105 mv opt/ usr/share/ $out
106
107 # `/opt/unityhub/unityhub` is a shell wrapper that runs `/opt/unityhub/unityhub-bin`
108 # Which we don't need and overwrite with our own custom wrapper
109 makeWrapper ${fhsEnv}/bin/${pname}-fhs-env $out/opt/unityhub/unityhub \
110 --add-flags $out/opt/unityhub/unityhub-bin \
111 --argv0 unityhub
112
113 # Link binary
114 mkdir -p $out/bin
115 ln -s $out/opt/unityhub/unityhub $out/bin/unityhub
116
117 # Replace absolute path in desktop file to correctly point to nix store
118 substituteInPlace $out/share/applications/unityhub.desktop \
119 --replace /opt/unityhub/unityhub $out/opt/unityhub/unityhub
120
121 runHook postInstall
122 '';
123
124 passthru.updateScript = ./update.sh;
125
126 meta = with lib; {
127 description = "Official Unity3D app to download and manage Unity Projects and installations";
128 homepage = "https://unity3d.com/";
129 license = licenses.unfree;
130 maintainers = with maintainers; [ tesq0 huantian ];
131 platforms = [ "x86_64-linux" ];
132 };
133}