Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 267 lines 5.7 kB view raw
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.2"; 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-7Fj238JdOzYDiOGS+GUGjWmqsJtNffAh+Q4xTS+lTzc="; 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 [ 115 bison 116 cmake 117 gettext 118 gobject-introspection 119 gperf 120 ninja 121 perl 122 perl.pkgs.FileCopyRecursive # used by copy-user-interface-resources.pl 123 pkg-config 124 python3 125 ruby 126 gi-docgen 127 glib # for gdbus-codegen 128 unifdef 129 ] 130 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 131 wayland-scanner 132 ]; 133 134 buildInputs = 135 [ 136 at-spi2-core 137 cairo # required even when using skia 138 enchant2 139 flite 140 libavif 141 libepoxy 142 libjxl 143 gnutls 144 gst-plugins-bad 145 gst-plugins-base 146 harfbuzz 147 hyphen 148 icu 149 libGL 150 libGLU 151 libgbm 152 libgcrypt 153 libgpg-error 154 libidn 155 libintl 156 lcms2 157 libpthreadstubs 158 libsysprof-capture 159 libtasn1 160 libwebp 161 libxkbcommon 162 libxml2 163 libxslt 164 libbacktrace 165 nettle 166 p11-kit 167 sqlite 168 woff2 169 ] 170 ++ lib.optionals clangStdenv.hostPlatform.isBigEndian [ 171 # https://bugs.webkit.org/show_bug.cgi?id=274032 172 fontconfig 173 freetype 174 ] 175 ++ lib.optionals clangStdenv.hostPlatform.isDarwin [ 176 libedit 177 readline 178 ] 179 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 180 libseccomp 181 libmanette 182 wayland 183 xorg.libX11 184 ] 185 ++ lib.optionals systemdSupport [ 186 systemd 187 ] 188 ++ lib.optionals enableGeoLocation [ 189 geoclue2 190 ] 191 ++ lib.optionals enableExperimental [ 192 # For ENABLE_WEB_RTC 193 openssl 194 ] 195 ++ lib.optionals withLibsecret [ 196 libsecret 197 ] 198 ++ lib.optionals (lib.versionAtLeast gtk3.version "4.0") [ 199 wayland-protocols 200 ]; 201 202 propagatedBuildInputs = [ 203 gtk3 204 libsoup 205 ]; 206 207 cmakeFlags = 208 let 209 cmakeBool = x: if x then "ON" else "OFF"; 210 in 211 [ 212 "-DENABLE_INTROSPECTION=ON" 213 "-DPORT=GTK" 214 "-DUSE_SOUP2=${cmakeBool (lib.versions.major libsoup.version == "2")}" 215 "-DUSE_LIBSECRET=${cmakeBool withLibsecret}" 216 "-DENABLE_EXPERIMENTAL_FEATURES=${cmakeBool enableExperimental}" 217 ] 218 ++ lib.optionals clangStdenv.hostPlatform.isLinux [ 219 # Have to be explicitly specified when cross. 220 # https://github.com/WebKit/WebKit/commit/a84036c6d1d66d723f217a4c29eee76f2039a353 221 "-DBWRAP_EXECUTABLE=${lib.getExe bubblewrap}" 222 "-DDBUS_PROXY_EXECUTABLE=${lib.getExe xdg-dbus-proxy}" 223 ] 224 ++ lib.optionals clangStdenv.hostPlatform.isDarwin [ 225 "-DENABLE_GAMEPAD=OFF" 226 "-DENABLE_GTKDOC=OFF" 227 "-DENABLE_MINIBROWSER=OFF" 228 "-DENABLE_QUARTZ_TARGET=ON" 229 "-DENABLE_X11_TARGET=OFF" 230 "-DUSE_APPLE_ICU=OFF" 231 "-DUSE_OPENGL_OR_ES=OFF" 232 ] 233 ++ lib.optionals (lib.versionOlder gtk3.version "4.0") [ 234 "-DUSE_GTK4=OFF" 235 ] 236 ++ lib.optionals (!systemdSupport) [ 237 "-DENABLE_JOURNALD_LOG=OFF" 238 ]; 239 240 postPatch = '' 241 patchShebangs . 242 ''; 243 244 postFixup = '' 245 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. 246 moveToOutput "share/doc" "$devdoc" 247 ''; 248 249 requiredSystemFeatures = [ "big-parallel" ]; 250 251 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 252 253 meta = with lib; { 254 description = "Web content rendering engine, GTK port"; 255 mainProgram = "WebKitWebDriver"; 256 homepage = "https://webkitgtk.org/"; 257 license = licenses.bsd2; 258 pkgConfigModules = [ 259 "javascriptcoregtk-4.0" 260 "webkit2gtk-4.0" 261 "webkit2gtk-web-extension-4.0" 262 ]; 263 platforms = platforms.linux ++ platforms.darwin; 264 teams = [ teams.gnome ]; 265 broken = clangStdenv.hostPlatform.isDarwin; 266 }; 267})