nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 gn,
4 ninja,
5 llvmPackages_21,
6 gclient2nix,
7 pkg-config,
8 glib,
9 python3,
10 symlinkJoin,
11 lib,
12 libxi,
13 libxext,
14 libx11,
15 libxcb,
16 wayland,
17 pciutils,
18 libGL,
19 apple-sdk_15,
20 xcbuild,
21}:
22let
23 llvmPackages = llvmPackages_21;
24 llvmMajorVersion = lib.versions.major llvmPackages.llvm.version;
25 arch = stdenv.hostPlatform.parsed.cpu.name;
26 triplet = lib.getAttr arch {
27 "x86_64" = "x86_64-unknown-linux-gnu";
28 "aarch64" = "aarch64-unknown-linux-gnu";
29 };
30
31 clang = symlinkJoin {
32 name = "angle-clang-llvm-join";
33 paths = [
34 llvmPackages.llvm
35 llvmPackages.clang
36 ];
37 postBuild =
38 if stdenv.isDarwin then
39 ''
40 mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/darwin
41 ln -s $out/resource-root/lib/darwin/libclang_rt.osx.a \
42 $out/lib/clang/${llvmMajorVersion}/lib/darwin/libclang_rt.osx.a
43 ln -s $out/resource-root/lib/darwin/libclang_rt.osx.a \
44 $out/lib/clang/${llvmMajorVersion}/lib/darwin/libclang_rt.osx-${arch}.a
45 ''
46 else
47 ''
48 mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/
49 ln -s $out/resource-root/lib/linux \
50 $out/lib/clang/${llvmMajorVersion}/lib/${triplet}
51 '';
52 };
53in
54stdenv.mkDerivation (finalAttrs: {
55 pname = "angle";
56 version = "7258";
57
58 gclientDeps = gclient2nix.importGclientDeps ./info.json;
59 sourceRoot = "src";
60 strictDeps = true;
61
62 nativeBuildInputs = [
63 gn
64 ninja
65 gclient2nix.gclientUnpackHook
66 pkg-config
67 python3
68 llvmPackages.bintools
69 ]
70 ++ lib.optionals stdenv.isDarwin [
71 xcbuild
72 ];
73
74 buildInputs =
75 lib.optionals stdenv.isLinux [
76 glib
77 libxcb.dev
78 libx11.dev
79 libxext.dev
80 libxi
81 wayland.dev
82 pciutils
83 libGL
84 ]
85 ++ lib.optionals stdenv.isDarwin [
86 apple-sdk_15
87 ];
88
89 gnFlags = [
90 "is_debug=false"
91 "use_sysroot=false"
92 "clang_base_path=\"${clang}\""
93 "angle_build_tests=false"
94 "concurrent_links=1"
95 "use_custom_libcxx=true"
96 "angle_enable_swiftshader=false"
97 "angle_enable_wgpu=false"
98 # On darwin during linking:
99 # clang++: error: argument unused during compilation: '-stdlib=libc++'
100 "treat_warnings_as_errors=false"
101 ];
102
103 patches = [
104 # https://issues.chromium.org/issues/432275627
105 # https://chromium-review.googlesource.com/c/chromium/src/+/6761936/2/build/config/compiler/BUILD.gn
106 ./fix-uninitialized-const-pointer-error-001.patch
107 ];
108
109 postPatch = ''
110 substituteInPlace build/config/clang/BUILD.gn \
111 --replace-fail \
112 "_dir = \"${triplet}\"" \
113 "_dir = \"${triplet}\"
114 _suffix = \"-${arch}\""
115
116 # Don't precompile Metal shaders, because the compiler is non-free.
117 substituteInPlace src/libANGLE/renderer/metal/metal_backend.gni \
118 --replace-fail \
119 "metal_internal_shader_compilation_supported =" \
120 "metal_internal_shader_compilation_supported = false &&"
121
122 cat > build/config/gclient_args.gni <<EOF
123 # Generated from 'DEPS'
124 checkout_angle_internal = false
125 checkout_angle_mesa = false
126 checkout_angle_restricted_traces = false
127 generate_location_tags = false
128 EOF
129
130 # For sandboxed build on darwin.
131 patchShebangs build/toolchain/apple
132 '';
133
134 installPhase = ''
135 runHook preInstall
136
137 install -v -m755 -D \
138 *${stdenv.hostPlatform.extensions.sharedLibrary}* \
139 -t "$out/lib"
140 install -v -m755 -D \
141 angle_shader_translator \
142 gaussian_distribution_gentables \
143 -t "$out/bin"
144
145 cp -rv ../../include "$out"
146
147 mkdir -p $out/lib/pkgconfig
148
149 cat > $out/lib/pkgconfig/angle.pc <<EOF
150 prefix=${placeholder "out"}
151 exec_prefix=''${prefix}
152 libdir=''${prefix}/lib
153 includedir=''${prefix}/include
154
155 Name: angle
156 Description: ${finalAttrs.meta.description}
157
158 URL: ${finalAttrs.meta.homepage}
159 Version: ${lib.versions.major finalAttrs.version}
160 Libs: -L''${libdir} -l${
161 lib.concatStringsSep " -l" [
162 "EGL"
163 "EGL_vulkan_secondaries"
164 "GLESv1_CM"
165 "GLESv2"
166 "GLESv2_vulkan_secondaries"
167 "GLESv2_with_capture"
168 "VkICD_mock_icd"
169 "feature_support"
170 ]
171 }
172 Cflags: -I''${includedir}
173 EOF
174
175 runHook postInstall
176 '';
177
178 meta = {
179 description = "Conformant OpenGL ES implementation for Windows, Mac, Linux, iOS and Android";
180 longDescription = ''
181 The goal of ANGLE is to allow users of multiple operating systems
182 to seamlessly run WebGL and other OpenGL ES content by translating
183 OpenGL ES API calls to one of the hardware-supported APIs available
184 for that platform.
185 '';
186 homepage = "https://angleproject.org";
187 maintainers = with lib.maintainers; [
188 jess
189 jk
190 ];
191 license = lib.licenses.bsd3;
192 platforms = lib.platforms.linux ++ lib.platforms.darwin;
193 };
194})