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 ++ extraLibs pkgs;
115 };
116
117 unpackCmd = "dpkg -x $curSrc src";
118
119 dontConfigure = true;
120 dontBuild = true;
121
122 installPhase = ''
123 runHook preInstall
124
125 mkdir -p $out
126 mv opt/ usr/share/ $out
127
128 # `/opt/unityhub/unityhub` is a shell wrapper that runs `/opt/unityhub/unityhub-bin`
129 # Which we don't need and overwrite with our own custom wrapper
130 makeWrapper ${fhsEnv}/bin/${pname}-fhs-env $out/opt/unityhub/unityhub \
131 --add-flags $out/opt/unityhub/unityhub-bin \
132 --argv0 unityhub
133
134 # Link binary
135 mkdir -p $out/bin
136 ln -s $out/opt/unityhub/unityhub $out/bin/unityhub
137
138 # Replace absolute path in desktop file to correctly point to nix store
139 substituteInPlace $out/share/applications/unityhub.desktop \
140 --replace /opt/unityhub/unityhub $out/opt/unityhub/unityhub
141
142 runHook postInstall
143 '';
144
145 passthru.updateScript = ./update.sh;
146
147 meta = with lib; {
148 description = "Official Unity3D app to download and manage Unity Projects and installations";
149 homepage = "https://unity.com/";
150 downloadPage = "https://unity.com/unity-hub";
151 changelog = "https://unity.com/unity-hub/release-notes";
152 license = licenses.unfree;
153 maintainers = with maintainers; [
154 tesq0
155 huantian
156 ];
157 platforms = [ "x86_64-linux" ];
158 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
159 };
160}