nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.15.4";
15
16 src = fetchurl {
17 url = "https://hub-dist.unity3d.com/artifactory/hub-debian-prod-local/pool/main/u/unity/unityhub_amd64/UnityHubSetup-${version}-amd64.deb";
18 hash = "sha256-O8rR4gLToJgUe8EsTvsk1AShGAAsgU4cy1+UITXiVm8=";
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 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 libxcomposite
71 libxext
72 libxdamage
73 libxfixes
74 libxcb
75 libxshmfence
76 libxscrnsaver
77 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 libx11
96 libxcursor
97 glib
98 gdk-pixbuf
99 libxml2_13
100 zlib
101 clang
102 git # for git-based packages in unity package manager
103
104 # Unity Editor 6000 specific dependencies
105 harfbuzz
106 vulkan-loader
107
108 # Unity Bug Reporter specific dependencies
109 libice
110 libsm
111
112 # Fonts used by built-in and third party editor tools
113 corefonts
114 dejavu_fonts
115 liberation_ttf
116 ]
117 ++ extraLibs pkgs;
118 };
119
120 dontConfigure = true;
121 dontBuild = true;
122
123 installPhase = ''
124 runHook preInstall
125
126 mkdir -p $out
127 mv opt/ usr/share/ $out
128
129 # `/opt/unityhub/unityhub` is a shell wrapper that runs `/opt/unityhub/unityhub-bin`
130 # which we don't need and overwrite with our own wrapper that uses the fhs env.
131 makeWrapper ${fhsEnv}/bin/${pname}-fhs-env $out/opt/unityhub/unityhub \
132 --add-flags $out/opt/unityhub/unityhub-bin \
133 --argv0 unityhub
134
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-fail /opt/unityhub/unityhub $out/opt/unityhub/unityhub
141
142 # This file is used by auto updater to determine whether this install is
143 # a .deb, .rpm, etc. Remove this to disable the auto updater, which auto
144 # downloads the update, in addition to being useless.
145 rm $out/opt/unityhub/resources/package-type
146
147 runHook postInstall
148 '';
149
150 passthru.updateScript = ./update.sh;
151
152 meta = {
153 description = "Official Unity3D app to download and manage Unity Projects and installations";
154 homepage = "https://unity.com/";
155 downloadPage = "https://unity.com/unity-hub";
156 changelog = "https://unity.com/unity-hub/release-notes#${version}";
157 license = lib.licenses.unfree;
158 maintainers = with lib.maintainers; [ huantian ];
159 platforms = [ "x86_64-linux" ];
160 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
161 };
162}