nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 callPackage,
4 stdenv,
5 fetchFromGitHub,
6 nix-update-script,
7 cmake,
8 python3,
9 gtest,
10 withAnimation ? true,
11 withTranscoder ? true,
12 eigen,
13 ghc_filesystem,
14}:
15
16let
17 cmakeBool = b: if b then "ON" else "OFF";
18 tinygltf = callPackage ./tinygltf.nix { };
19in
20stdenv.mkDerivation (finalAttrs: {
21 version = "1.5.7";
22 pname = "draco";
23
24 src = fetchFromGitHub {
25 owner = "google";
26 repo = "draco";
27 rev = finalAttrs.version;
28 hash = "sha256-p0Mn4kGeBBKL7Hoz4IBgb6Go6MdkgE7WZgxAnt1tE/0=";
29 fetchSubmodules = true;
30 };
31
32 # ld: unknown option: --start-group
33 postPatch = ''
34 substituteInPlace cmake/draco_targets.cmake \
35 --replace "^Clang" "^AppleClang"
36 '';
37
38 buildInputs = [
39 gtest
40 ]
41 ++ lib.optionals withTranscoder [
42 eigen
43 ghc_filesystem
44 tinygltf
45 ];
46
47 nativeBuildInputs = [
48 cmake
49 python3
50 ];
51
52 cmakeFlags = [
53 "-DDRACO_ANIMATION_ENCODING=${cmakeBool withAnimation}"
54 "-DDRACO_GOOGLETEST_PATH=${gtest}"
55 "-DBUILD_SHARED_LIBS=${cmakeBool true}"
56 "-DDRACO_TRANSCODER_SUPPORTED=${cmakeBool withTranscoder}"
57 ]
58 ++ lib.optionals withTranscoder [
59 "-DDRACO_EIGEN_PATH=${eigen}/include/eigen3"
60 "-DDRACO_FILESYSTEM_PATH=${ghc_filesystem}"
61 "-DDRACO_TINYGLTF_PATH=${tinygltf}"
62 ];
63
64 CXXFLAGS = [
65 # error: expected ')' before 'value' in 'explicit GltfValue(uint8_t value)'
66 "-include cstdint"
67 ];
68
69 passthru.updateScript = nix-update-script { };
70
71 meta = {
72 description = "Library for compressing and decompressing 3D geometric meshes and point clouds";
73 homepage = "https://google.github.io/draco/";
74 changelog = "https://github.com/google/draco/releases/tag/${finalAttrs.version}";
75 license = lib.licenses.asl20;
76 maintainers = with lib.maintainers; [ jansol ];
77 platforms = lib.platforms.all;
78 };
79})