-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
269 lines (246 loc) · 7.94 KB
/
flake.nix
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
{
description = "OpenEMS mesher draft";
nixConfig.bash-prompt-suffix = "(openemsh) ";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/22.11";
nix-filter.url = "github:numtide/nix-filter";
flake-utils.url = "github:numtide/flake-utils";
cmake-utils = {
url = "github:conformism/cmake-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self
, nixpkgs
, nix-filter
, cmake-utils
, flake-utils
, ...
}@inputs:
let
lib = nixpkgs.lib.extend nix-filter.overlays.default;
in flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [
cmake-utils.overlays.pkgs
self.overlays.pkgs
];
in {
devShells = {
default = pkgs.mkShell {
inputsFrom = [
pkgs.openemsh
pkgs.cmake-utils-full
];
packages = [
pkgs.openems
pkgs.appcsxcad
(pkgs.octave.withPackages (p: [
pkgs.octave-openems
pkgs.octave-csxcad
pkgs.octave-openems-hll
]))
];
};
doc = pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.numpy
python-pkgs.matplotlib
]))
];
};
};
packages = {
default = pkgs.openemsh;
openemsh = pkgs.openemsh;
};
}) // {
overlays = {
pkgs = final: prev: {
openemsh = prev.callPackage ./default.nix {
inherit lib;
stdenv = prev.llvmPackages_13.stdenv;
};
inherit (prev.python310Packages) cairosvg;
csxcad = (prev.csxcad.overrideAttrs (new: old: {
version = "0.6.3";
src = prev.fetchFromGitHub {
owner = "thliebig";
repo = "CSXCAD";
rev = "v${new.version}";
hash = "sha256-SSV5ulx3rCJg99I/oOQbqe+gOSs+BfcCo6UkWHVhnSs=";
};
prePatch = ''
substituteInPlace CMakeLists.txt --replace-fail 'INSTALL(DIRECTORY matlab DESTINATION share/CSXCAD)' ""
'';
outputs = [ "out" "dev" ];
})).override {
stdenv = prev.fastStdenv;
};
qcsxcad = (prev.qcsxcad.overrideAttrs (new: old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
prev.libsForQt5.wrapQtAppsHook
];
})).override {
mkDerivation = prev.fastStdenv.mkDerivation;
inherit (final) csxcad;
};
appcsxcad = (prev.appcsxcad.overrideAttrs (new: old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
prev.libsForQt5.wrapQtAppsHook
];
})).override {
mkDerivation = prev.fastStdenv.mkDerivation;
inherit (final) csxcad qcsxcad;
};
openems = (prev.openems.overrideAttrs (new: old: {
version = "0.0.36";
src = prev.fetchFromGitHub {
owner = "thliebig";
repo = "openEMS";
rev = "v${new.version}";
hash = "sha256-wdH+Zw7G2ZigzBMX8p3GKdFVx/AhbTNL+P3w+YjI/dc=";
};
postFixup = ""; # Avoid oct file building / setup.m patching.
prePatch = ''
substituteInPlace CMakeLists.txt --replace-fail 'INSTALL( DIRECTORY matlab DESTINATION share/openEMS )' ""
'';
outputs = [ "out" "dev" ];
})).override {
stdenv = prev.fastStdenv;
inherit (final) csxcad qcsxcad;
};
octave-csxcad = prev.octavePackages.buildOctavePackage rec {
inherit (final.csxcad) pname version meta src;
patchPhase =
let
description = ''
Name: csxcad
Version: ${version}
Date: 2016-07-06
Author: Thorsten Liebig
Maintainer: Thomas Lepoix <[email protected]>
Title: C++ library to describe geometrical objects
Description: Signal processing tools, including filtering, windowing and display functions.
Categories: Electromagnetics
License: GPLv3
Url: https://github.com/thliebig/CSXCAD
'';
in ''
sed -i matlab/CSXGeomPlot.m \
-e '30,36d'
substituteInPlace matlab/CSXGeomPlot.m --replace-fail \
"command = [AppCSXCAD_bin" \
"command = ['env AppCSXCAD'"
echo "TMPDIR: $TMPDIR"
mkdir -p $TMPDIR/out
mv ./NEWS $TMPDIR/out/
mv ./COPYING $TMPDIR/out/
mv ./matlab $TMPDIR/out/inst
cat > $TMPDIR/out/DESCRIPTION <<EOF
${description}
EOF
rm -rf *
mv $TMPDIR/out/* .
'';
propagatedBuildInputs = [
final.appcsxcad
];
};
octave-openems = prev.octavePackages.buildOctavePackage rec {
inherit (final.openems) pname version meta src;
requiredOctavePackages = [
final.octave-csxcad
];
buildInputs = [
prev.hdf5-cpp
];
propagatedBuildInputs = [
final.openems
final.appcsxcad
];
patchPhase =
let
description = ''
Name: openems
Version: ${version}
Date: 2016-07-06
Author: Thorsten Liebig
Maintainer: Thomas Lepoix <[email protected]>
Title: Electromagnetic field solver
Description: Signal processing tools, including filtering, windowing and display functions.
Categories: Electromagnetics
License: GPLv3
Url: https://github.com/thliebig/openEMS
'';
in ''
sed -i matlab/private/invoke_openEMS.m \
-e '29,35d'
substituteInPlace matlab/private/invoke_openEMS.m --replace-fail \
"command = [openEMS_bin" \
"command = ['env openEMS'"
sed -i matlab/CalcNF2FF.m \
-e '101,107d' \
-e '124,126d'
substituteInPlace matlab/CalcNF2FF.m --replace-fail \
"system(['export LD_LIBRARY_PATH=; ' nf2ff_bin" \
"system(['env nf2ff'"
mkdir -p $TMPDIR/out/
mv ./NEWS $TMPDIR/out/
mv ./COPYING $TMPDIR/out/
rm ./matlab/setup.m
mv ./matlab $TMPDIR/out/inst
cat > $TMPDIR/out/DESCRIPTION <<EOF
${description}
EOF
rm -rf *
mv $TMPDIR/out/* .
cd inst
mkoctfile \
-I${prev.hdf5-cpp}/include \
-L${prev.hdf5-cpp}/lib \
-lhdf5_cpp \
--verbose \
h5readatt_octave.cc
rm h5readatt_octave.cc
cd ..
'';
};
octave-openems-hll = prev.octavePackages.buildOctavePackage rec {
pname = "openems-hll";
version = "ec5e1c1";
src = prev.fetchFromGitHub {
owner = "Open-RFlab";
repo = "octave-openems-hll";
rev = version;
hash = "sha256-/RITOhGOwVjUuttDdiYQ7IaDhD7j9NB24PRI1tZRFJY=";
};
requiredOctavePackages = [
final.octave-openems
final.octave-csxcad
];
propagatedBuildInputs = [
prev.imagemagick
prev.graphicsmagick
prev.ghostscript
];
meta = {
homepage = "https://github.com/Open-RFlab/octave-openems-hll";
description = "OpenEMS High-level layer";
license = prev.lib.licenses.gpl3;
maintainers = [
{
email = "[email protected]";
github = "thomaslepoix";
githubId = 26417323;
name = "Thomas Lepoix";
}
];
};
};
};
};
};
}