Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesa: split out the Darwin build into a separate expression #319047

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkgs/applications/misc/blender/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ stdenv.mkDerivation (finalAttrs: {
};

tests = {
render = runCommand "${finalAttrs.pname}-test" { } ''
render = runCommand "${finalAttrs.pname}-test" {
nativeBuildInputs = [ mesa.llvmpipeHook ];
} ''
set -euo pipefail
export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib/dri
export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
cat <<'PYTHON' > scene-config.py
import bpy
bpy.context.scene.eevee.taa_render_samples = 32
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/networking/browsers/chromium/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ let
pciutils protobuf speechd libXdamage at-spi2-core
pipewire
libva
libdrm wayland mesa.drivers libxkbcommon
libdrm wayland libxkbcommon
curl
libepoxy
libffi
Expand Down Expand Up @@ -227,7 +227,7 @@ let
pciutils protobuf speechd libXdamage at-spi2-core
pipewire
libva
libdrm wayland mesa.drivers libxkbcommon
libdrm wayland libxkbcommon
curl
libepoxy
libffi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ stdenv.mkDerivation rec {
libnotify
libpulseaudio
libxkbcommon
mesa.drivers
nss
xorg.libX11
xorg.libXScrnSaver
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/co/cosmic-edit/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ rustPlatform.buildRustPackage rec {
wrapProgram "$out/bin/${pname}" \
--suffix XDG_DATA_DIRS : "${cosmic-icons}/share" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr vulkan-loader libxkbcommon mesa.drivers wayland
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr vulkan-loader libxkbcommon wayland
]}
'';

Expand Down
1 change: 0 additions & 1 deletion pkgs/by-name/co/cosmic-store/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ rustPlatform.buildRustPackage rec {
xorg.libXrandr
libxkbcommon
vulkan-loader
mesa.drivers
]
}
'';
Expand Down
1 change: 0 additions & 1 deletion pkgs/by-name/co/cosmic-term/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ rustPlatform.buildRustPackage rec {
--suffix XDG_DATA_DIRS : "${cosmic-icons}/share" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [
libxkbcommon
mesa.drivers
vulkan-loader
xorg.libX11
xorg.libXcursor
Expand Down
9 changes: 6 additions & 3 deletions pkgs/by-name/op/openscad-unstable/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ clangStdenv.mkDerivation rec {
"-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld"
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
];

doCheck = true;

nativeCheckInputs = [
mesa.llvmpipeHook
];

checkPhase = ''
# for running mesa llvmpipe
export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib:${mesa.drivers}/lib/dri
# some fontconfig issues cause pdf output to have wrong font
ctest -j$NIX_BUILD_CORES -E pdfexporttest.\*
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/common/llvm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ stdenv.mkDerivation (rec {
)
'';

# E.g. mesa.drivers use the build-id as a cache key (see #93946):
# E.g. Mesa uses the build-id as a cache key (see #93946):
LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";

cmakeBuildType = if debugVersion then "Debug" else "Release";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/libva/1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
# TODO: share libs between minimal and !minimal - perhaps just symlink them

# Add FHS paths for non-NixOS applications.
configureFlags = [ "--with-drivers-path=${mesa.drivers.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri" ]
configureFlags = lib.optionals stdenv.isLinux [ "--with-drivers-path=${mesa.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri" ]
++ lib.optionals (!minimal) [ "--enable-glx" ];

installFlags = [ "dummy_drv_video_ladir=$(out)/lib/dri" ];
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/libraries/libva/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [ libdrm ]
++ lib.optionals (!minimal) [ libX11 libXext libXfixes wayland libffi libGL ];

mesonFlags = [
mesonFlags = lib.optionals stdenv.isLinux [
# Add FHS and Debian paths for non-NixOS applications
"-Ddriverdir=${mesa.drivers.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/i386-linux-gnu/dri"
"-Ddriverdir=${mesa.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/i386-linux-gnu/dri"
];

passthru.tests = {
Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/libraries/libvdpau/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ stdenv.mkDerivation rec {

propagatedBuildInputs = [ xorg.libX11 ];

mesonFlags = lib.optionals stdenv.isLinux
[ "-Dmoduledir=${mesa.drivers.driverLink}/lib/vdpau" ];
mesonFlags = lib.optionals stdenv.isLinux [ "-Dmoduledir=${mesa.driverLink}/lib/vdpau" ];

NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-lX11";

Expand Down
32 changes: 32 additions & 0 deletions pkgs/development/libraries/mesa/common.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib, fetchurl }:
rec {
pname = "mesa";
version = "24.1.1";

src = fetchurl {
urls = [
"https://archive.mesa3d.org/mesa-${version}.tar.xz"
"https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz"
];
hash = "sha256-ADiCbG9+iNkLTOb3GRkvpYyn3t9O3KoRdM972SDvieo=";
};

meta = {
description = "Open source 3D graphics library";
longDescription = ''
The Mesa project began as an open-source implementation of the OpenGL
specification - a system for rendering interactive 3D graphics. Over the
years the project has grown to implement more graphics APIs, including
OpenGL ES (versions 1, 2, 3), OpenCL, OpenMAX, VDPAU, VA API, XvMC, and
Vulkan. A variety of device drivers allows the Mesa libraries to be used
in many different environments ranging from software emulation to
complete hardware acceleration for modern GPUs.
'';
homepage = "https://www.mesa3d.org/";
changelog = "https://www.mesa3d.org/relnotes/${version}.html";
license = with lib.licenses; [ mit ]; # X11 variant, in most files
platforms = lib.platforms.mesaPlatforms;
badPlatforms = []; # Load bearing for libGL meta on Darwin.
maintainers = with lib.maintainers; [ primeos vcunat ]; # Help is welcome :)
};
}
59 changes: 59 additions & 0 deletions pkgs/development/libraries/mesa/darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# The Darwin build of Mesa is different enough that we just give it an entire separate expression.
{
lib,
stdenv,
fetchurl,
bison,
flex,
meson,
ninja,
pkg-config,
python3Packages,
Xplugin,
xorg,
zlib,
}:
let
common = import ./common.nix { inherit lib fetchurl; };
in stdenv.mkDerivation {
inherit (common) pname version src meta;

patches = [
# Reorder things to make it build on Darwin again
# Submitted upstream: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29592
# FIXME: remove when merged or otherwise addressed
./darwin.patch
];

outputs = [ "out" "dev" ];

nativeBuildInputs = [
bison
flex
meson
ninja
pkg-config
python3Packages.python
python3Packages.mako
];

buildInputs = [
Xplugin
xorg.libX11
xorg.libXext
xorg.libXfixes
zlib
];

mesonAutoFeatures = "disabled";

mesonFlags = [
"--sysconfdir=/etc"
"--datadir=${placeholder "out"}/share"
(lib.mesonEnable "glvnd" false)
(lib.mesonEnable "shared-glapi" true)
];

# Don't need this on Darwin.
passthru.llvmpipeHook = null;
}
Loading