diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/mesa/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/mesa/default.nix | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/nixpkgs/pkgs/development/libraries/mesa/default.nix b/nixpkgs/pkgs/development/libraries/mesa/default.nix index 7eb18dd31c1..cf452fded14 100644 --- a/nixpkgs/pkgs/development/libraries/mesa/default.nix +++ b/nixpkgs/pkgs/development/libraries/mesa/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchurl, fetchpatch +{ stdenv, lib, fetchurl, fetchpatch, buildPackages , pkgconfig, intltool, ninja, meson , file, flex, bison, expat, libdrm, xorg, wayland, wayland-protocols, openssl , llvmPackages, libffi, libomxil-bellagio, libva-minimal @@ -11,6 +11,8 @@ , eglPlatforms ? [ "x11" "surfaceless" ] ++ lib.optionals stdenv.isLinux [ "wayland" "drm" ] , OpenGL, Xplugin , withValgrind ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32, valgrind-light +, enableGalliumNine ? stdenv.isLinux +, enableOSMesa ? stdenv.isLinux }: /** Packaging design: @@ -27,7 +29,9 @@ with stdenv.lib; let - version = "20.0.2"; + # Release calendar: https://www.mesa3d.org/release-calendar.html + # Release frequency: https://www.mesa3d.org/releasing.html#schedule + version = "20.1.7"; branch = versions.major version; in @@ -37,12 +41,12 @@ stdenv.mkDerivation { src = fetchurl { urls = [ + "https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz" "ftp://ftp.freedesktop.org/pub/mesa/mesa-${version}.tar.xz" "ftp://ftp.freedesktop.org/pub/mesa/${version}/mesa-${version}.tar.xz" "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz" - "https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz" ]; - sha256 = "0vz8k07d23qdwy67fnna9y0ynnni0m8lgswcmdm60l4mcv5z2m5a"; + sha256 = "1252mgwiy05nz8mm4gjkzmnjfvdz5yv1shnsr837cdnan86dvsad"; }; prePatch = "patchShebangs ."; @@ -54,7 +58,22 @@ stdenv.mkDerivation { ./missing-includes.patch # dev_t needs sys/stat.h, time_t needs time.h, etc.-- fixes build w/musl ./opencl-install-dir.patch ./disk_cache-include-dri-driver-path-in-cache-key.patch - ] # do not prefix user provided dri-drivers-path + ./link-radv-with-ld_args_build_id.patch + ] + ++ lib.optionals stdenv.hostPlatform.isMusl [ + # Fix `-Werror=int-conversion` pthread warnings on musl. + # TODO: Remove when https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6121 is merged and available + (fetchpatch { + name = "nine_debug-Make-tid-more-type-correct"; + # Patch adjusted for version `20.1`, before the big mesa dirs change + # `gallium: rename 'state tracker' to 'frontend'`. + # Patch for versions after that change is at + # https://gitlab.freedesktop.org/mesa/mesa/commit/aebbf819df6d1e3b4745ef16d0e833300ad67044.patch + url = "https://gitlab.freedesktop.org/nh2/mesa/commit/3385c49684375f1153a52ed7ccda3f5135268a41.patch"; + sha256 = "1ci694sqjll44c9g2md4krhk6qlvq51r7ad5rnnfdnf3l8ys0i50"; + }) + ] + # do not prefix user provided dri-drivers-path ++ lib.optional (lib.versionOlder version "19.0.0") (fetchpatch { url = "https://gitlab.freedesktop.org/mesa/mesa/commit/f6556ec7d126b31da37c08d7cb657250505e01a0.patch"; sha256 = "0z6phi8hbrbb32kkp1js7ggzviq7faz1ria36wi4jbc4in2392d9"; @@ -73,11 +92,24 @@ stdenv.mkDerivation { }) ]; - outputs = [ "out" "dev" "drivers" "osmesa" ]; + postPatch = '' + substituteInPlace meson.build --replace \ + "find_program('pkg-config')" \ + "find_program('${buildPackages.pkg-config.targetPrefix}pkg-config')" + + # The drirc.d directory cannot be installed to $drivers as that would cause a cyclic dependency: + substituteInPlace src/util/xmlconfig.c --replace \ + 'DATADIR "/drirc.d"' '"${placeholder "out"}/drirc.d"' + substituteInPlace src/util/meson.build --replace \ + "get_option('datadir')" "'${placeholder "out"}'" + ''; + + outputs = [ "out" "dev" "drivers" ] ++ lib.optional enableOSMesa "osmesa"; # TODO: Figure out how to enable opencl without having a runtime dependency on clang mesonFlags = [ "--sysconfdir=/etc" + "--datadir=${placeholder "drivers"}/share" # Vendor files # Don't build in debug mode # https://gitlab.freedesktop.org/mesa/mesa/blob/master/docs/meson.html#L327 @@ -97,10 +129,10 @@ stdenv.mkDerivation { "-Domx-libs-path=${placeholder "drivers"}/lib/bellagio" "-Dva-libs-path=${placeholder "drivers"}/lib/dri" "-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d" + "-Dgallium-nine=${if enableGalliumNine then "true" else "false"}" # Direct3D in Wine + "-Dosmesa=${if enableOSMesa then "gallium" else "none"}" # used by wine ] ++ optionals stdenv.isLinux [ "-Dglvnd=true" - "-Dosmesa=gallium" # used by wine - "-Dgallium-nine=true" # Direct3D in Wine ]; buildInputs = with xorg; [ @@ -112,10 +144,14 @@ stdenv.mkDerivation { ++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal ] ++ lib.optional withValgrind valgrind-light; + depsBuildBuild = [ pkgconfig ]; + nativeBuildInputs = [ pkgconfig meson ninja intltool bison flex file python3Packages.python python3Packages.Mako + ] ++ lib.optionals (elem "wayland" eglPlatforms) [ + wayland # For wayland-scanner during the build ]; propagatedBuildInputs = with xorg; [ @@ -132,20 +168,17 @@ stdenv.mkDerivation { '' + optionalString stdenv.isLinux '' mkdir -p $drivers/lib - # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM - mv -t $drivers/lib \ - $out/lib/libxatracker* \ - $out/lib/libvulkan_* + if [ -n "$(shopt -s nullglob; echo "$out/lib/libxatracker"*)" -o -n "$(shopt -s nullglob; echo "$out/lib/libvulkan_"*)" ]; then + # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM + mv -t $drivers/lib \ + $out/lib/libxatracker* \ + $out/lib/libvulkan_* + fi - # Move other drivers to a separate output - mv $out/lib/lib*_mesa* $drivers/lib - - # move libOSMesa to $osmesa, as it's relatively big - mkdir -p $osmesa/lib - mv -t $osmesa/lib/ $out/lib/libOSMesa* - - # move vendor files - mv $out/share/ $drivers/ + if [ -n "$(shopt -s nullglob; echo "$out"/lib/lib*_mesa*)" ]; then + # Move other drivers to a separate output + mv $out/lib/lib*_mesa* $drivers/lib + fi # Update search path used by glvnd for js in $drivers/share/glvnd/egl_vendor.d/*.json; do @@ -157,6 +190,10 @@ stdenv.mkDerivation { for js in $drivers/share/vulkan/icd.d/*.json; do substituteInPlace "$js" --replace "$out" "$drivers" done + '' + lib.optionalString enableOSMesa '' + # move libOSMesa to $osmesa, as it's relatively big + mkdir -p $osmesa/lib + mv -t $osmesa/lib/ $out/lib/libOSMesa* ''; # TODO: @@ -171,7 +208,9 @@ stdenv.mkDerivation { # Update search path used by pkg-config for pc in $dev/lib/pkgconfig/{d3d,dri,xatracker}.pc; do - substituteInPlace "$pc" --replace $out $drivers + if [ -f "$pc" ]; then + substituteInPlace "$pc" --replace $out $drivers + fi done # add RPATH so the drivers can find the moved libgallium and libdricore9 @@ -205,6 +244,6 @@ stdenv.mkDerivation { changelog = "https://www.mesa3d.org/relnotes/${version}.html"; license = licenses.mit; # X11 variant, in most files platforms = platforms.mesaPlatforms; - maintainers = with maintainers; [ vcunat ]; + maintainers = with maintainers; [ primeos vcunat ]; # Help is welcome :) }; } |