18 , vulkan-memory-allocator
21 , enableVulkan ? !stdenv.hostPlatform.isDarwin
24 stdenv.mkDerivation (finalAttrs: {
26 # Version from https://skia.googlesource.com/skia/+/refs/heads/main/RELEASE_NOTES.md
27 # or https://chromiumdash.appspot.com/releases
28 # plus date of the tip of the corresponding chrome/m$version branch
29 version = "129-unstable-2024-09-18";
32 url = "https://skia.googlesource.com/skia.git";
33 # Tip of the chrome/m$version branch
34 rev = "dda581d538cb6532cda841444e7b4ceacde01ec9";
35 hash = "sha256-NZiZFsABebugszpYsBusVlTYnYda+xDIpT05cZ8Jals=";
39 # System zlib detection bug workaround
40 substituteInPlace BUILD.gn \
41 --replace-fail 'deps = [ "//third_party/zlib" ]' 'deps = []'
49 ] ++ lib.optional stdenv.hostPlatform.isDarwin xcbuild;
61 ] ++ lib.optionals enableVulkan [
63 vulkan-memory-allocator
72 }.${stdenv.hostPlatform.parsed.cpu.name};
74 # Build in release mode
75 "is_official_build=true"
76 "is_component_build=true"
77 # Don't use missing tools
78 "skia_use_dng_sdk=false"
79 "skia_use_wuffs=false"
80 # Use system dependencies
81 "extra_cflags=[\"-I${harfbuzzFull.dev}/include/harfbuzz\"]"
82 "cc=\"${stdenv.cc.targetPrefix}cc\""
83 "cxx=\"${stdenv.cc.targetPrefix}c++\""
84 "ar=\"${stdenv.cc.targetPrefix}ar\""
85 "target_cpu=\"${cpu}\""
86 ] ++ map (lib: "skia_use_system_${lib}=true") [
91 ] ++ lib.optionals enableVulkan [
92 "skia_use_vulkan=true"
95 # Somewhat arbitrary, but similar to what other distros are doing
105 find . -name '*.h' -exec install -Dm644 {} $out/include/skia/{} \;
108 find . -name '*.h' -exec install -Dm644 {} $out/include/skia/modules/{} \;
112 mkdir -p $out/lib/pkgconfig
113 cat > $out/lib/pkgconfig/skia.pc <<'EOF'
114 prefix=${placeholder "out"}
115 exec_prefix=''${prefix}
116 libdir=''${prefix}/lib
117 includedir=''${prefix}/include/skia
119 Description: 2D graphic library for drawing text, geometries and images.
120 URL: https://skia.org/
121 Version: ${lib.versions.major finalAttrs.version}
122 Libs: -L''${libdir} -lskia
123 Cflags: -I''${includedir}
130 # Some skia includes are assumed to be under an include sub directory by
132 for file in $(grep -rl '#include "include/' $out/include); do
133 substituteInPlace "$file" \
134 --replace-fail '#include "include/' '#include "'
138 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
141 description = "2D graphic library for drawing text, geometries and images";
142 homepage = "https://skia.org/";
143 license = lib.licenses.bsd3;
144 maintainers = with lib.maintainers; [ fgaz ];
145 platforms = with lib.platforms; arm ++ aarch64 ++ x86 ++ x86_64;
146 pkgConfigModules = [ "skia" ];
147 # https://github.com/NixOS/nixpkgs/pull/325871#issuecomment-2220610016
148 broken = stdenv.hostPlatform.isDarwin;