@@ -1,13 +1,53 @@
1−{ fetchFromGitHub, libGLU, llvmPackages, qtbase, qtscript, qtxmlpatterns }:
1+{ mkDerivation, lib, fetchFromGitHub
2+, fetchpatch
3+, libGLU
4+, qtbase
5+, qtscript
6+, qtxmlpatterns
7+, lib3ds
8+, bzip2
9+, muparser
10+, levmar
11+}:
212
313let
4− meshlabRev = "d596d7c086c51fbdfb56050f9c30b55dd0286d4c";
5− vcglibRev = "6c3c940e34327322507c703889f9f1cfa73ab183";
14+ meshlabRev = "25f3d17b1d1d47ddc51179cb955f3027b7638745";
15+ vcglibRev = "910da4c3e310f2e6557bd7a39c4f1529e61573e5";
616 # ^ 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.
721
8− stdenv = llvmPackages.stdenv; # only building with clang seems to be tested upstream
9−in stdenv.mkDerivation {
10− name = "meshlab-20180627-beta";
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";
29+ };
30+
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";
1151
1252 srcs =
1353 [
@@ -15,38 +55,54 @@ in stdenv.mkDerivation {
1555 owner = "cnr-isti-vclab";
1656 repo = "meshlab";
1757 rev = meshlabRev;
18− sha256 = "0xi7wiyy0yi545l5qvccbqahlcsf70mhx829gf7bq29640si4rax";
58+ sha256 = "16d2i91hrxvrr5p0k33g3fzis9zp4gsy3n5y2nhafvsgdmaidiij";
1959 name = "meshlab-${meshlabRev}";
2060 })
2161 (fetchFromGitHub {
2262 owner = "cnr-isti-vclab";
2363 repo = "vcglib";
2464 rev = vcglibRev;
25− sha256 = "0jfgjvf21y9ncmyr7caipy3ardhig7hh9z8miy885c99b925hhwd";
65+ sha256 = "0xpnjpwpj57hgai184rzyk9lbq6d9vbjzr477dvl5nplpwa420m1";
2666 name = "vcglib-${vcglibRev}";
2767 })
2868 ];
2969
3070 sourceRoot = "meshlab-${meshlabRev}";
3171
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+ # ^~~~~~~
3276 hardeningDisable = [ "format" ];
77+
3378 enableParallelBuilding = true;
3479
35− patches = [ ./fix-20180627-beta.patch ];
80+ prePatch =
81+ ''
82+ # MeshLab has ../vcglib hardcoded everywhere, so move the source dir
83+ mv ../vcglib-${vcglibRev} ../vcglib
3684
37− buildPhase = ''
38− # MeshLab has ../vcglib hardcoded everywhere, so move the source dir
39− mv ../vcglib-${vcglibRev} ../vcglib
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}
4089
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 = ''
4198 cd src
4299 export NIX_LDFLAGS="-rpath $out/opt/meshlab $NIX_LDFLAGS"
43− export QMAKESPEC="linux-clang"
44100
45101 pushd external
46− qmake -recursive external.pro
102+ qmake -recursive $QMAKE_FLAGS external.pro
47103 buildPhase
48104 popd
49− qmake -recursive meshlab_full.pro
105+ qmake -recursive $QMAKE_FLAGS meshlab_full.pro
50106 buildPhase
51107 '';
52108
@@ -57,13 +113,22 @@ in stdenv.mkDerivation {
57113 ln -s $out/opt/meshlab/meshlabserver $out/bin/meshlabserver
58114 '';
59115
60− buildInputs = [ libGLU llvmPackages.openmp qtbase qtscript qtxmlpatterns ];
116+ buildInputs = [
117+ libGLU
118+ qtbase
119+ qtscript
120+ qtxmlpatterns
121+ lib3ds
122+ bzip2
123+ muparser
124+ levmar
125+ ];
61126
62127 meta = {
63128 description = "A system for processing and editing 3D triangular meshes.";
64129 homepage = http://www.meshlab.net/;
65− license = stdenv.lib.licenses.gpl3;
66− maintainers = with stdenv.lib.maintainers; [viric];
67− platforms = with stdenv.lib.platforms; linux;
130+ license = lib.licenses.gpl3;
131+ maintainers = with lib.maintainers; [viric];
132+ platforms = with lib.platforms; linux;
68133 };
69134}