nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5
6 # build system
7 meson,
8 ninja,
9 pkg-config,
10
11 # deps
12 dbus,
13 dri-pkgconfig-stub,
14 fontutil,
15 libdrm,
16 libepoxy,
17 libgbm,
18 libGL,
19 libGLU,
20 libpciaccess,
21 libtirpc,
22 libunwind,
23 libx11,
24 libxau,
25 libxcb,
26 libxcb-image,
27 libxcb-keysyms,
28 libxcb-render-util,
29 libxcb-util,
30 libxcb-wm,
31 libxcvt,
32 libxdmcp,
33 libxext,
34 libxfixes,
35 libxfont_1,
36 libxfont_2,
37 libxkbfile,
38 libxshmfence,
39 mesa,
40 mesa-gl-headers,
41 openssl,
42 pixman,
43 udev,
44 xkbcomp,
45 xkeyboardconfig,
46 xorgproto,
47 xtrans,
48 zlib,
49
50 # darwin specific deps
51 darwin,
52 utilmacros,
53 libapplewm,
54
55 writeScript,
56 testers,
57}:
58stdenv.mkDerivation (finalAttrs: {
59 pname = "xorg-server";
60 version = "21.1.21";
61
62 outputs = [
63 "out"
64 "dev"
65 ];
66
67 src = fetchurl {
68 url = "mirror://xorg/individual/xserver/xorg-server-${finalAttrs.version}.tar.xz";
69 hash = "sha256-wMvlVFs/ZFuuYCS4MNHRFUqVY1BoOk5Ssv/1sPoatRk=";
70 };
71
72 patches = lib.optionals stdenv.hostPlatform.isDarwin [
73 ./darwin/bundle_main.patch
74 ./darwin/find-cpp.patch
75 ./darwin/stub.patch
76 ];
77
78 strictDeps = true;
79
80 nativeBuildInputs = [
81 meson
82 ninja
83 pkg-config
84 ]
85 ++ lib.optionals stdenv.hostPlatform.isDarwin [
86 darwin.bootstrap_cmds
87 utilmacros
88 ];
89
90 buildInputs = [
91 fontutil
92 libx11
93 libxau
94 libxcb
95 libxcb-image
96 libxcb-keysyms
97 libxcb-render-util
98 libxcb-util
99 libxcb-wm
100 libxcvt
101 libxdmcp
102 libxfixes
103 libxkbfile
104 mesa-gl-headers
105 openssl
106 xorgproto
107 xtrans
108 ]
109 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
110 dri-pkgconfig-stub
111 libdrm
112 libgbm
113 ]
114 ++ lib.optionals stdenv.hostPlatform.isLinux [
115 libtirpc
116 ]
117 ++ lib.optionals stdenv.hostPlatform.isDarwin [
118 darwin.bootstrap_cmds
119 mesa
120 ];
121
122 propagatedBuildInputs = [
123 dbus
124 libepoxy
125 libGL
126 libGLU
127 libunwind
128 libxext
129 libxfont_1
130 libxfont_2
131 libxshmfence
132 pixman
133 xorgproto
134 zlib
135 ]
136 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ libpciaccess ]
137 ++ lib.optionals stdenv.hostPlatform.isLinux [ udev ]
138 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libapplewm ];
139
140 mesonFlags = [
141 "-Dxephyr=true"
142 "-Dxvfb=true"
143 "-Dxnest=true"
144 "-Dxorg=true"
145
146 "-Dlog_dir=/var/log"
147 "-Ddefault_font_path="
148
149 "-Dxkb_bin_dir=${xkbcomp}/bin"
150 "-Dxkb_dir=${xkeyboardconfig}/share/X11/xkb"
151 "-Dxkb_output_dir=$out/share/X11/xkb/compiled"
152 ]
153 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
154 "-Dxcsecurity=true"
155 ]
156 ++ lib.optionals stdenv.hostPlatform.isDarwin [
157 "-Dglamor=false"
158 "-Dsecure-rpc=false"
159 "-Dint10=false"
160 "-Dpciaccess=false"
161 "-Dapple-application-name=XQuartz"
162 "-Dapple-applications-dir=${placeholder "out"}/Applications"
163 "-Dbundle-id-prefix=org.nixos.xquartz"
164 "-Dsha1=CommonCrypto"
165 ]
166 ++ lib.optionals (!stdenv.hostPlatform.isLinux) [
167 # fixed upstream (unreleased)
168 "-Dudev=false"
169 "-Dudev_kms=false"
170 ];
171
172 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
173 substituteInPlace hw/xquartz/mach-startup/stub.c \
174 --subst-var-by XQUARTZ_APP "$out/Applications/XQuartz.app"
175 '';
176
177 # default X install symlinks this to Xorg, we want XQuartz
178 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
179 ln -sf $out/bin/Xquartz $out/bin/X
180 '';
181
182 passthru = {
183 inherit (finalAttrs) version; # needed by virtualbox guest additions
184 updateScript = writeScript "update-${finalAttrs.pname}" ''
185 #!/usr/bin/env nix-shell
186 #!nix-shell -i bash -p common-updater-scripts
187 version="$(list-directory-versions --pname ${finalAttrs.pname} \
188 --url https://xorg.freedesktop.org/releases/individual/xserver/ \
189 | sort -V | tail -n1)"
190 update-source-version ${finalAttrs.pname} "$version"
191 '';
192 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
193 };
194
195 meta = {
196 description = "X server implementation by X.org";
197 longDescription = ''
198 The X server accepts requests from client applications to create windows, which are (normally
199 rectangular) "virtual screens" that the client program can draw into.
200 Windows are then composed on the actual screen by the X server (or by a separate composite
201 manager) as directed by the window manager, which usually communicates with the user via
202 graphical controls such as buttons and draggable titlebars and borders.
203
204 For a comprehensive overview of X Server and X Window System, consult the following article:
205 https://en.wikipedia.org/wiki/X_server
206 '';
207 homepage = "https://x.org/wiki";
208 license = with lib.licenses; [
209 # because the license list is huge (1848 lines) this is documented by line range
210 # https://gitlab.freedesktop.org/xorg/xserver/-/blob/f05f269f1d5bddafe71cdfb290b118820bf17fdd/COPYING
211
212 # 10-45, 148-170, 364-390, 431-454, 485-511, 512-534, 535-558, 1573-1593, 1692-1711, 1760-1779
213 mit
214
215 # 53-77, 124-147, 317-343, 455-484, 559-583, 629-654, 891-918, 1008-1034, 1056-1079,
216 # 1296-1326, 1438-1470, 1499-1522, 1523-1548
217 x11
218
219 # 78-99, 171-191, 391-430 (doubled text), 584-605, 606-628, 707-729, 730-750, 807-828,
220 # 829-853, 854-879, 880-890, 919-939, 940-962, 963-985, 986-1007, 1035-1055, 1080-1102,
221 # 1103-1125, 1126-1148, 1149-1169, 1170-1192, 1193-1215, 1216-1236, 1237-1259, 1275-1295,
222 # 1327-1359, 1360-1383, 1549-1572, 1594-1617, 1618-1638, 1639-1670, 1671-1691, 1712-1732,
223 # 1733-1756, 1795-1814
224 hpndSellVariant
225
226 mitOpenGroup # 100-123
227 hpnd # 192-214, 215-237, 344-363, 686-706, 1416-1437
228 dec3Clause # 238-267
229 x11NoPermitPersons # 268-292
230 # missing last paragraph likely due to an error
231 # https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2097
232 sgi-b-20 # 293-316
233 bsd3 # 655-685, 1471-1498, 1815-1848 (BSD-4-Clause UC with rescinded third clause)
234 adobeDisplayPostScript # 751-782
235 ntp # 783-795
236 hpndUc # 796-806
237 isc # 1260-1274
238 icu # 1383-1415
239 # missing author/copyright notice
240 # https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2098
241 hpndSellVariantMitDisclaimerXserver # 1780-1793
242 ];
243 mainProgram = "X";
244 maintainers = [ ];
245 pkgConfigModules = [ "xorg-server" ];
246 platforms = lib.platforms.unix;
247 };
248})