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
|
{ stdenv
, fetchFromGitLab
, python
, libxml2
, sqlite
, boost
, gtk3-x11
, root
, glib
, gsl
, cmake
, pkg-config
, libpcap
, jansson
, harfbuzz
, freetype
# for binding generation
, castxml ? null
, cppyy ? null
# can take a long time, generates > 30000 images/graphs
, enableDoxygen ? false
# very long
, withManual ? false
, doxygen ? null
, graphviz ? null
, imagemagick ? null
# for manual, tetex is used to get the eps2pdf binary
# texlive to get latexmk. building manual still fails though
, dia
, tetex ? null
, ghostscript ? null
, texliveMedium ? null
# generates python bindings
, pythonSupport ? true
, ncurses ? null
, lib
}:
let
pythonEnv = python.withPackages (ps:
lib.optional withManual ps.sphinx
++ lib.optionals pythonSupport (with ps;[ pybindgen pygccxml cppyy])
);
in
stdenv.mkDerivation rec {
pname = "ns-3";
version = "39";
src = fetchFromGitLab {
owner = "nsnam";
repo = "ns-3-dev";
rev = "ns-3.${version}";
sha256 = "sha256-2d8xCCfxRpcCZgt7ne17F7cUo/wIxLyvjQs3izNUnmY=";
};
nativeBuildInputs = [ cmake pkg-config pythonEnv ];
outputs = [ "out" ];
# ncurses is a hidden dependency of waf when checking python
buildInputs = lib.optionals pythonSupport [ castxml ncurses ]
++ lib.optionals enableDoxygen [ doxygen graphviz imagemagick ]
++ lib.optionals withManual [ dia tetex ghostscript imagemagick texliveMedium ]
++ [
libxml2
pythonEnv
sqlite.dev
gsl
boost
root # provides cppyy
glib.out
glib.dev
libpcap
gtk3-x11.dev
harfbuzz
freetype
jansson
];
propagatedBuildInputs = [ pythonEnv ];
preConfigure = ''
substituteInPlace src/tap-bridge/CMakeLists.txt \
--replace '-DTAP_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/' "-DTAP_CREATOR=\"$out/libexec/ns3/"
substituteInPlace src/fd-net-device/CMakeLists.txt \
--replace '-DRAW_SOCK_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DRAW_SOCK_CREATOR=\"$out/libexec/ns3/"
substituteInPlace src/fd-net-device/CMakeLists.txt \
--replace '-DTAP_DEV_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DTAP_DEV_CREATOR=\"$out/libexec/ns3/"
'';
doCheck = false;
buildTargets = "build"
+ lib.optionalString enableDoxygen " doxygen"
+ lib.optionalString withManual "sphinx";
# to prevent fatal error: 'backward_warning.h' file not found
CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH";
# Make generated python bindings discoverable in customized python environment
passthru = { pythonModule = python; };
cmakeFlags = [
"-DPython3_LIBRARY_DIRS=${pythonEnv}/lib"
"-DPython3_INCLUDE_DIRS=${pythonEnv}/include"
"-DPython3_EXECUTABLE=${pythonEnv}/bin/python"
"-DNS3_PYTHON_BINDINGS=ON"
"-DNS3_DES_METRICS=ON"
"-DNS3_BINDINGS_INSTALL_DIR=${pythonEnv.sitePackages}"
"-DNS3_LOG=ON"
"-DNS3_ASSERT=ON"
"-DNS3_GTK3=ON"
"-DGTK3_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
]
++ lib.optional doCheck "-DNS3_TESTS=ON";
# strictoverflow prevents clang from discovering pyembed when bindings
hardeningDisable = [ "fortify" "strictoverflow" ];
meta = with lib; {
homepage = "http://www.nsnam.org";
license = licenses.gpl3;
description = "A discrete time event network simulator";
platforms = with platforms; unix;
maintainers = with maintainers; [ teto rgrunbla ];
# never built on aarch64-darwin since first introduction in nixpkgs
broken = (stdenv.isDarwin && stdenv.isAarch64) || (stdenv.isLinux && stdenv.isAarch64);
};
}
|