@@ -7,112 +7,26 @@
77, lib3ds
88, bzip2
99, muparser
10+, eigen
11+, glew
12+, gmp
1013, levmar
14+, qhull
15+, cmake
1116}:
1217
13−let
14− meshlabRev = "25f3d17b1d1d47ddc51179cb955f3027b7638745";
15− vcglibRev = "910da4c3e310f2e6557bd7a39c4f1529e61573e5";
16− # ^ this should be the latest commit in the vcglib devel branch at the time of the meshlab revision
17− # We keep it separate here instead of using the `vcg` nix package because
18− # as of writing, meshlab upstream does not seem to follow a proper
19− # release process, and the other dependencies of `vcg` may no longer
20− # work when we upgrade it for the purpose of meshlab.
18+mkDerivation rec {
19+ pname = "meshlab";
20+ version = "2020.03";
2121
22− # Unfixed upstream compile error; see
23− # https://github.com/cnr-isti-vclab/meshlab/issues/188#issuecomment-364785362
24− # that has with fixed line endings.
25− import_bundle_out_patch = fetchpatch {
26− name = "import_bundle_out.patch";
27− url = "https://aur.archlinux.org/cgit/aur.git/plain/import_bundle_out.patch?h=meshlab-git&id=f7250ea818470f07dc9b86726407091d39c0be6f";
28− sha256 = "1g6nli15i3fjd6jsgkxvb33kzbcv67xjkc3jv9r51lrwlm1ifzxi";
22+ src = fetchFromGitHub {
23+ owner = "cnr-isti-vclab";
24+ repo = "meshlab";
25+ rev = "f3568e75c9aed6da8bb105a1c8ac7ebbe00e4536";
26+ sha256 = "17g9icgy1w67afxiljzxk94dyhj4f336gjxn0bhppd58xfqh8w4g";
27+ fetchSubmodules = true; # for vcglib
2928 };
3029
31− # Reduces amount of vendored libraries, fixes `/linux` vs `linux-g++`
32− # directory name linker errors.
33− external_patch = fetchpatch {
34− name = "external.patch";
35− url = "https://aur.archlinux.org/cgit/aur.git/plain/external.patch?h=meshlab-git&id=f7250ea818470f07dc9b86726407091d39c0be6f";
36− sha256 = "1rxwkxhmxis1420rc1w7dg89gkmym68lpszsq6snl6dzpl3ingsb";
37− };
38− _3ds_patch = fetchpatch {
39− name = "3ds.patch";
40− url = "https://aur.archlinux.org/cgit/aur.git/plain/3ds.patch?h=meshlab-git&id=f7250ea818470f07dc9b86726407091d39c0be6f";
41− sha256 = "1w435b7p1ggi2bzib4yyszmk54drjgpbn8n9mnsk1slsxnp2vmg8";
42− };
43− muparser_patch = fetchpatch {
44− name = "muparser.patch";
45− url = "https://aur.archlinux.org/cgit/aur.git/plain/muparser.patch?h=meshlab-git&id=f7250ea818470f07dc9b86726407091d39c0be6f";
46− sha256 = "1sf7xqwc2j8xxdx2yklwifii9qqgknvx6ahk2hq76mg78ry1nzhq";
47− };
48−
49−in mkDerivation {
50− name = "meshlab-20190129-beta";
51−
52− srcs =
53− [
54− (fetchFromGitHub {
55− owner = "cnr-isti-vclab";
56− repo = "meshlab";
57− rev = meshlabRev;
58− sha256 = "16d2i91hrxvrr5p0k33g3fzis9zp4gsy3n5y2nhafvsgdmaidiij";
59− name = "meshlab-${meshlabRev}";
60− })
61− (fetchFromGitHub {
62− owner = "cnr-isti-vclab";
63− repo = "vcglib";
64− rev = vcglibRev;
65− sha256 = "0xpnjpwpj57hgai184rzyk9lbq6d9vbjzr477dvl5nplpwa420m1";
66− name = "vcglib-${vcglibRev}";
67− })
68− ];
69−
70− sourceRoot = "meshlab-${meshlabRev}";
71−
72− # Meshlab is not format-security clean; without disabling hardening, we get:
73− # ../../external/qhull-2003.1/src/io.c:2169:3: error: format not a string literal and no format arguments [-Werror=format-security]
74− # fprintf(fp, endfmt);
75− # ^~~~~~~
76− hardeningDisable = [ "format" ];
77−
78− enableParallelBuilding = true;
79−
80− prePatch =
81− ''
82− # MeshLab has ../vcglib hardcoded everywhere, so move the source dir
83− mv ../vcglib-${vcglibRev} ../vcglib
84−
85− # Make all source files writable so that patches can be applied.
86− chmod -R u+w ..
87−
88− patch -Np1 --directory=../vcglib -i ${import_bundle_out_patch}
89−
90− patch -Np1 -i ${external_patch}
91− # Individual libraries
92− patch -Np1 -i ${_3ds_patch}
93− patch -Np1 -i ${muparser_patch}
94− ''
95− ;
96−
97− buildPhase = ''
98− cd src
99− export NIX_LDFLAGS="-rpath $out/opt/meshlab $NIX_LDFLAGS"
100−
101− pushd external
102− qmake -recursive $QMAKE_FLAGS external.pro
103− buildPhase
104− popd
105− qmake -recursive $QMAKE_FLAGS meshlab_full.pro
106− buildPhase
107− '';
108−
109− installPhase = ''
110− mkdir -p $out/opt/meshlab $out/bin
111− cp -Rv distrib/* $out/opt/meshlab
112− ln -s $out/opt/meshlab/meshlab $out/bin/meshlab
113− ln -s $out/opt/meshlab/meshlabserver $out/bin/meshlabserver
114− '';
115−
11630 buildInputs = [
11731 libGLU
11832 qtbase
@@ -121,9 +35,49 @@ in mkDerivation {
12135 lib3ds
12236 bzip2
12337 muparser
38+ eigen
39+ glew
40+ gmp
12441 levmar
42+ qhull
43+ ];
44+
45+ nativeBuildInputs = [ cmake ];
46+
47+ patches = [ ./no-build-date.patch ];
48+
49+ # MeshLab computes the version based on the build date, remove when https://github.com/cnr-isti-vclab/meshlab/issues/622 is fixed.
50+ postPatch = ''
51+ substituteAll ${./fix-version.patch} /dev/stdout | patch -p1 --binary
52+ '';
53+
54+ preConfigure = ''
55+ substituteAll ${./meshlab.desktop} install/linux/resources/meshlab.desktop
56+ cd src
57+ '';
58+
59+ cmakeFlags = [
60+ "-DALLOW_BUNDLED_EIGEN=OFF"
61+ "-DALLOW_BUNDLED_GLEW=OFF"
62+ "-DALLOW_BUNDLED_LIB3DS=OFF"
63+ "-DALLOW_BUNDLED_MUPARSER=OFF"
64+ "-DALLOW_BUNDLED_QHULL=OFF"
65+ # disable when available in nixpkgs
66+ "-DALLOW_BUNDLED_OPENCTM=ON"
67+ "-DALLOW_BUNDLED_SSYNTH=ON"
68+ # some plugins are disabled unless these are on
69+ "-DALLOW_BUNDLED_NEWUOA=ON"
70+ "-DALLOW_BUNDLED_LEVMAR=ON"
12571 ];
12672
73+ # Meshlab is not format-security clean; without disabling hardening, we get:
74+ # src/common/GLLogStream.h:61:37: error: format not a string literal and no format arguments [-Werror=format-security]
75+ # 61 | int chars_written = snprintf(buf, buf_size, f, std::forward<Ts>(ts)...);
76+ # |
77+ hardeningDisable = [ "format" ];
78+
79+ enableParallelBuilding = true;
80+
12781 meta = {
12882 description = "A system for processing and editing 3D triangular meshes.";
12983 homepage = "http://www.meshlab.net/";