Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 clangStdenv, 4 buildPackages, 5 runCommand, 6 fetchurl, 7 perl, 8 python3, 9 ruby, 10 gi-docgen, 11 bison, 12 gperf, 13 cmake, 14 ninja, 15 pkg-config, 16 gettext, 17 gobject-introspection, 18 gnutls, 19 libgcrypt, 20 libgpg-error, 21 gtk3, 22 wayland, 23 wayland-protocols, 24 wayland-scanner, 25 libwebp, 26 enchant2, 27 xorg, 28 libxkbcommon, 29 libavif, 30 libepoxy, 31 libjxl, 32 at-spi2-core, 33 cairo, 34 libxml2, 35 libsoup, 36 libsecret, 37 libxslt, 38 harfbuzz, 39 hyphen, 40 icu, 41 libsysprof-capture, 42 libpthreadstubs, 43 nettle, 44 libtasn1, 45 p11-kit, 46 libidn, 47 libedit, 48 readline, 49 libGL, 50 libGLU, 51 libgbm, 52 libintl, 53 lcms2, 54 libmanette, 55 geoclue2, 56 flite, 57 fontconfig, 58 freetype, 59 openssl, 60 sqlite, 61 gst-plugins-base, 62 gst-plugins-bad, 63 woff2, 64 bubblewrap, 65 libseccomp, 66 libbacktrace, 67 systemd, 68 xdg-dbus-proxy, 69 replaceVars, 70 glib, 71 unifdef, 72 addDriverRunpath, 73 enableGeoLocation ? true, 74 enableExperimental ? false, 75 withLibsecret ? true, 76 systemdSupport ? lib.meta.availableOn clangStdenv.hostPlatform systemd, 77 testers, 78}: 79 80# https://webkitgtk.org/2024/10/04/webkitgtk-2.46.html recommends building with clang. 81clangStdenv.mkDerivation (finalAttrs: { 82 pname = "webkitgtk"; 83 version = "2.48.5"; 84 name = "${finalAttrs.pname}-${finalAttrs.version}+abi=${ 85 if lib.versionAtLeast gtk3.version "4.0" then 86 "6.0" 87 else 88 "4.${if lib.versions.major libsoup.version == "2" then "0" else "1"}" 89 }"; 90 91 outputs = [ 92 "out" 93 "dev" 94 "devdoc" 95 ]; 96 97 # https://github.com/NixOS/nixpkgs/issues/153528 98 # Can't be linked within a 4GB address space. 99 separateDebugInfo = clangStdenv.hostPlatform.isLinux && !clangStdenv.hostPlatform.is32bit; 100 101 src = fetchurl { 102 url = "https://webkitgtk.org/releases/webkitgtk-${finalAttrs.version}.tar.xz"; 103 hash = "sha256-u2TtnRz9WOi16JzK1x3TGt/tVjNrrXaVAxrQtmjhmHw="; 104 }; 105 106 patches = lib.optionals clangStdenv.hostPlatform.isLinux [ 107 (replaceVars ./fix-bubblewrap-paths.patch { 108 inherit (builtins) storeDir; 109 inherit (addDriverRunpath) driverLink; 110 }) 111 ]; 112 113 nativeBuildInputs = [ 114 bison 115 cmake 116 gettext 117 gobject-introspection 118 gperf 119 ninja 120 perl 121 perl.pkgs.FileCopyRecursive # used by copy-user-interface-resources.pl 122 pkg-config 123 python3 124 ruby 125 gi-docgen 126 glib # for gdbus-codegen 127 unifdef 128 ] 129 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 130 wayland-scanner 131 ]; 132 133 buildInputs = [ 134 at-spi2-core 135 cairo # required even when using skia 136 enchant2 137 flite 138 libavif 139 libepoxy 140 libjxl 141 gnutls 142 gst-plugins-bad 143 gst-plugins-base 144 harfbuzz 145 hyphen 146 icu 147 libGL 148 libGLU 149 libgbm 150 libgcrypt 151 libgpg-error 152 libidn 153 libintl 154 lcms2 155 libpthreadstubs 156 libsysprof-capture 157 libtasn1 158 libwebp 159 libxkbcommon 160 libxml2 161 libxslt 162 libbacktrace 163 nettle 164 p11-kit 165 sqlite 166 woff2 167 ] 168 ++ lib.optionals clangStdenv.hostPlatform.isBigEndian [ 169 # https://bugs.webkit.org/show_bug.cgi?id=274032 170 fontconfig 171 freetype 172 ] 173 ++ lib.optionals clangStdenv.hostPlatform.isDarwin [ 174 libedit 175 readline 176 ] 177 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 178 libseccomp 179 libmanette 180 wayland 181 xorg.libX11 182 ] 183 ++ lib.optionals systemdSupport [ 184 systemd 185 ] 186 ++ lib.optionals enableGeoLocation [ 187 geoclue2 188 ] 189 ++ lib.optionals enableExperimental [ 190 # For ENABLE_WEB_RTC 191 openssl 192 ] 193 ++ lib.optionals withLibsecret [ 194 libsecret 195 ] 196 ++ lib.optionals (lib.versionAtLeast gtk3.version "4.0") [ 197 wayland-protocols 198 ]; 199 200 propagatedBuildInputs = [ 201 gtk3 202 libsoup 203 ]; 204 205 cmakeFlags = 206 let 207 cmakeBool = x: if x then "ON" else "OFF"; 208 in 209 [ 210 "-DENABLE_INTROSPECTION=ON" 211 "-DPORT=GTK" 212 "-DUSE_SOUP2=${cmakeBool (lib.versions.major libsoup.version == "2")}" 213 "-DUSE_LIBSECRET=${cmakeBool withLibsecret}" 214 "-DENABLE_EXPERIMENTAL_FEATURES=${cmakeBool enableExperimental}" 215 ] 216 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 217 # Have to be explicitly specified when cross. 218 # https://github.com/WebKit/WebKit/commit/a84036c6d1d66d723f217a4c29eee76f2039a353 219 "-DBWRAP_EXECUTABLE=${lib.getExe bubblewrap}" 220 "-DDBUS_PROXY_EXECUTABLE=${lib.getExe xdg-dbus-proxy}" 221 ] 222 ++ lib.optionals clangStdenv.hostPlatform.isDarwin [ 223 "-DENABLE_GAMEPAD=OFF" 224 "-DENABLE_GTKDOC=OFF" 225 "-DENABLE_MINIBROWSER=OFF" 226 "-DENABLE_QUARTZ_TARGET=ON" 227 "-DENABLE_X11_TARGET=OFF" 228 "-DUSE_APPLE_ICU=OFF" 229 "-DUSE_OPENGL_OR_ES=OFF" 230 ] 231 ++ lib.optionals (lib.versionOlder gtk3.version "4.0") [ 232 "-DUSE_GTK4=OFF" 233 ] 234 ++ lib.optionals (!systemdSupport) [ 235 "-DENABLE_JOURNALD_LOG=OFF" 236 ]; 237 238 postPatch = '' 239 patchShebangs . 240 ''; 241 242 postFixup = '' 243 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. 244 moveToOutput "share/doc" "$devdoc" 245 ''; 246 247 requiredSystemFeatures = [ "big-parallel" ]; 248 249 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 250 251 meta = with lib; { 252 description = "Web content rendering engine, GTK port"; 253 mainProgram = "WebKitWebDriver"; 254 homepage = "https://webkitgtk.org/"; 255 license = licenses.bsd2; 256 pkgConfigModules = [ 257 "javascriptcoregtk-4.0" 258 "webkit2gtk-4.0" 259 "webkit2gtk-web-extension-4.0" 260 ]; 261 platforms = platforms.linux ++ platforms.darwin; 262 teams = [ teams.gnome ]; 263 broken = clangStdenv.hostPlatform.isDarwin; 264 }; 265})