1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
{ lib
, cmake
, coin3d
, doxygen
, eigen
, fetchFromGitHub
, fmt
, freecad # for passthru.tests
, gfortran
, gts
, hdf5
, libGLU
, libXmu
, libf2c
, libredwg
, libsForQt5
, libspnav
, medfile
, mpi
, ninja
, ode
, opencascade-occt
, pkg-config
, python3Packages
, runCommand # for passthru.tests
, spaceNavSupport ? stdenv.isLinux
, stdenv
, swig
, vtk
, wrapGAppsHook
, xercesc
, zlib
}:
let
boost = python3Packages.boost;
inherit (libsForQt5)
qtbase
qttools
qtwebengine
qtx11extras
qtxmlpatterns
soqt
wrapQtAppsHook;
inherit (python3Packages)
gitpython
matplotlib
pivy
ply
pycollada
pyside2
pyside2-tools
python
pyyaml
scipy
shiboken2;
in
stdenv.mkDerivation (finalAttrs: {
pname = "freecad";
version = "0.21.2";
src = fetchFromGitHub {
owner = "FreeCAD";
repo = "FreeCAD";
rev = finalAttrs.version;
hash = "sha256-OX4s9rbGsAhH7tLJkUJYyq2A2vCdkq/73iqYo9adogs=";
};
nativeBuildInputs = [
cmake
ninja
pkg-config
pyside2-tools
gfortran
wrapQtAppsHook
wrapGAppsHook
];
buildInputs = [
gitpython # for addon manager
boost
coin3d
doxygen
eigen
fmt
gts
hdf5
libGLU
libXmu
libf2c
matplotlib
medfile
mpi
ode
opencascade-occt
pivy
ply # for openSCAD file support
pycollada
pyside2
pyside2-tools
python
pyyaml # (at least for) PyrateWorkbench
qtbase
qttools
qtwebengine
qtxmlpatterns
scipy
shiboken2
soqt
swig
vtk
xercesc
zlib
] ++ lib.optionals spaceNavSupport [
libspnav
qtx11extras
];
patches = [
./0001-NIXOS-don-t-ignore-PYTHONPATH.patch
];
cmakeFlags = [
"-Wno-dev" # turns off warnings which otherwise makes it hard to see what is going on
"-DBUILD_FLAT_MESH:BOOL=ON"
"-DBUILD_QT5=ON"
"-DSHIBOKEN_INCLUDE_DIR=${shiboken2}/include"
"-DSHIBOKEN_LIBRARY=Shiboken2::libshiboken"
("-DPYSIDE_INCLUDE_DIR=${pyside2}/include"
+ ";${pyside2}/include/PySide2/QtCore"
+ ";${pyside2}/include/PySide2/QtWidgets"
+ ";${pyside2}/include/PySide2/QtGui"
)
"-DPYSIDE_LIBRARY=PySide2::pyside2"
];
# This should work on both x86_64, and i686 linux
preBuild = ''
export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS";
'';
preConfigure = ''
qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
'';
qtWrapperArgs = [
"--set COIN_GL_NO_CURRENT_CONTEXT_CHECK 1"
"--prefix PATH : ${libredwg}/bin"
"--set QT_QPA_PLATFORM xcb"
];
postFixup = ''
mv $out/share/doc $out
ln -s $out/bin/FreeCAD $out/bin/freecad
ln -s $out/bin/FreeCADCmd $out/bin/freecadcmd
'';
passthru.tests = {
# Check that things such as argument parsing still work correctly with
# the above PYTHONPATH patch. Previously the patch used above changed
# the `PyConfig_InitIsolatedConfig` to `PyConfig_InitPythonConfig`,
# which caused the built-in interpreter to attempt (and fail) to doubly
# parse argv. This should catch if that ever regresses and also ensures
# that PYTHONPATH is still respected enough for the FreeCAD console to
# successfully run and check that it was included in `sys.path`.
python-path = runCommand "freecad-test-console" {
nativeBuildInputs = [ freecad ];
} ''
HOME="$(mktemp -d)" PYTHONPATH="$(pwd)/test" FreeCADCmd --log-file $out -c "if not '$(pwd)/test' in sys.path: sys.exit(1)" </dev/null
'';
};
meta = {
homepage = "https://www.freecad.org";
description = "General purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler";
longDescription = ''
FreeCAD is an open-source parametric 3D modeler made primarily to design
real-life objects of any size. Parametric modeling allows you to easily
modify your design by going back into your model history and changing its
parameters.
FreeCAD allows you to sketch geometry constrained 2D shapes and use them
as a base to build other objects. It contains many components to adjust
dimensions or extract design details from 3D models to create high quality
production ready drawings.
FreeCAD is designed to fit a wide range of uses including product design,
mechanical engineering and architecture. Whether you are a hobbyist, a
programmer, an experienced CAD user, a student or a teacher, you will feel
right at home with FreeCAD.
'';
license = lib.licenses.lgpl2Plus;
maintainers = with lib.maintainers; [ viric gebner AndersonTorres ];
platforms = lib.platforms.linux;
};
})
|