1{
2 stdenv,
3 fetchzip,
4 ghostscript,
5 lib,
6 texliveMedium,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "fastcap";
11 version = "2.0-18Sep92";
12
13 src = fetchzip {
14 url = "https://www.rle.mit.edu/cpg/codes/fastcap-${version}.tgz";
15 hash = "sha256-fnmC6WNd7xk8fphxkMZUq2+Qz+2mWIP2lvBUBAmUvHI";
16 stripRoot = false;
17 };
18
19 patches = [
20 ./fastcap-mulglobal-drop-conflicting-lib.patch
21 ./fastcap-mulsetup-add-forward-declarations.patch
22 ];
23
24 nativeBuildInputs = [
25 ghostscript
26 texliveMedium
27 ];
28
29 postPatch = ''
30 substituteInPlace ./doc/Makefile \
31 --replace '/bin/rm' 'rm'
32
33 for f in "doc/*.tex" ; do
34 sed -i -E $f \
35 -e 's/\\special\{psfile=([^,]*),.*scale=([#0-9.]*).*\}/\\includegraphics[scale=\2]{\1}/' \
36 -e 's/\\psfig\{figure=([^,]*),.*width=([#0-9.]*in).*\}/\\includegraphics[width=\2]{\1}/' \
37 -e 's/\\psfig\{figure=([^,]*),.*height=([#0-9.]*in).*\}/\\includegraphics[height=\2]{\1}/' \
38 -e 's/\\psfig\{figure=([^,]*)\}/\\includegraphics{\1}/'
39 done
40
41 for f in "doc/mtt.tex" "doc/tcad.tex" "doc/ug.tex"; do
42 sed -i -E $f \
43 -e 's/^\\documentstyle\[(.*)\]\{(.*)\}/\\documentclass[\1]{\2}\n\\usepackage{graphicx}\n\\usepackage{robinspace}/' \
44 -e 's/\\setlength\{\\footheight\}\{.*\}/%/' \
45 -e 's/\\setstretch\{.*\}/%/'
46 done
47 '';
48
49 dontConfigure = true;
50
51 makeFlags = [
52 "RM=rm"
53 "SHELL=sh"
54 "all"
55 ];
56
57 # GCC 14 makes these errors by default
58 env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration -Wno-error=return-mismatch -Wno-error=implicit-int";
59
60 outputs = [
61 "out"
62 "doc"
63 ];
64
65 postBuild = ''
66 make manual
67 pushd doc
68 find -name '*.dvi' -exec dvipdf {} \;
69 popd
70 '';
71
72 installPhase = ''
73 runHook preInstall
74
75 mkdir -p $out/
76 mv bin $out/bin
77 rm $out/bin/README
78
79 mkdir -p $doc/share/doc/fastcap-${version}
80 cp doc/*.pdf $doc/share/doc/fastcap-${version}
81
82 mkdir -p $out/share/fastcap
83 mv examples $out/share/fastcap
84
85 runHook postInstall
86 '';
87
88 meta = with lib; {
89 description = "Multipole-accelerated capacitance extraction program";
90 longDescription = ''
91 Fastcap is a three dimensional capacitance extraction program that
92 compute self and mutual capacitances between conductors of arbitrary
93 shapes, sizes and orientations.
94 '';
95 homepage = "https://www.rle.mit.edu/cpg/research_codes.htm";
96 license = licenses.mit;
97 maintainers = with maintainers; [ fbeffa ];
98 platforms = platforms.linux;
99 mainProgram = "fastcap";
100 };
101}