1{ lib, stdenv, fetchFromGitHub, cmake, nix-update-script }:
2
3let
4 basis_universal = fetchFromGitHub {
5 owner = "zeux";
6 repo = "basis_universal";
7 rev = "8903f6d69849fd782b72a551a4dd04a264434e20";
8 hash = "sha256-o3dCxAAkpMoNkvkM7qD75cPn/obDc/fJ8u7KLPm1G6g=";
9 };
10in stdenv.mkDerivation rec {
11 pname = "meshoptimizer";
12 version = "0.20";
13 src = fetchFromGitHub {
14 owner = "zeux";
15 repo = "meshoptimizer";
16 rev = "v${version}";
17 hash = "sha256-QCxpM2g8WtYSZHkBzLTJNQ/oHb5j/n9rjaVmZJcCZIA=";
18 };
19
20 nativeBuildInputs = [ cmake ];
21
22 outputs = [ "bin" "dev" "out" ];
23
24 cmakeFlags = [
25 "-DMESHOPT_BUILD_GLTFPACK=ON"
26 "-DMESHOPT_BASISU_PATH=${basis_universal}"
27 ] ++ lib.optional (!stdenv.hostPlatform.isStatic)
28 "-DMESHOPT_BUILD_SHARED_LIBS:BOOL=ON";
29
30 passthru.updateScript = nix-update-script { };
31
32 meta = with lib; {
33 description = "Mesh optimization library that makes meshes smaller and faster to render";
34 homepage = "https://github.com/zeux/meshoptimizer";
35 license = licenses.mit;
36 maintainers = [ maintainers.lillycham ];
37 platforms = platforms.all;
38 mainProgram = "gltfpack";
39 };
40}