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