foundationdb: pin Boost 1.86 and fix Makefile (#376230)
[NixPkgs.git] / pkgs / development / libraries / science / networking / ns-3 / default.nix
bloba69b6c27b6b0f3bc2757db7f3cd2ea9eaf9cebaa
2   stdenv,
3   fetchFromGitLab,
4   python,
5   libxml2,
6   sqlite,
8   boost,
9   gtk3-x11,
10   root,
11   glib,
12   gsl,
14   cmake,
15   pkg-config,
17   libpcap,
19   jansson,
21   harfbuzz,
22   freetype,
24   # for binding generation
25   castxml ? null,
26   cppyy ? null,
28   # can take a long time, generates > 30000 images/graphs
29   enableDoxygen ? false,
31   # very long
32   withManual ? false,
33   doxygen ? null,
34   graphviz ? null,
35   imagemagick ? null,
36   # for manual, tetex is used to get the eps2pdf binary
37   # texlive to get latexmk. building manual still fails though
38   dia,
39   tetex ? null,
40   ghostscript ? null,
41   texliveMedium ? null,
43   # generates python bindings
44   pythonSupport ? true,
45   ncurses ? null,
47   lib,
50 let
51   pythonEnv = python.withPackages (
52     ps:
53     lib.optional withManual ps.sphinx
54     ++ lib.optionals pythonSupport (
55       with ps;
56       [
57         pybindgen
58         pygccxml
59         cppyy
60       ]
61     )
62   );
64 stdenv.mkDerivation rec {
65   pname = "ns-3";
66   version = "39";
68   src = fetchFromGitLab {
69     owner = "nsnam";
70     repo = "ns-3-dev";
71     rev = "ns-3.${version}";
72     hash = "sha256-2d8xCCfxRpcCZgt7ne17F7cUo/wIxLyvjQs3izNUnmY=";
73   };
75   nativeBuildInputs = [
76     cmake
77     pkg-config
78     pythonEnv
79   ];
81   outputs = [ "out" ];
83   # ncurses is a hidden dependency of waf when checking python
84   buildInputs =
85     lib.optionals pythonSupport [
86       castxml
87       ncurses
88     ]
89     ++ lib.optionals enableDoxygen [
90       doxygen
91       graphviz
92       imagemagick
93     ]
94     ++ lib.optionals withManual [
95       dia
96       tetex
97       ghostscript
98       imagemagick
99       texliveMedium
100     ]
101     ++ [
102       libxml2
103       pythonEnv
104       sqlite.dev
105       gsl
106       boost
107       root # provides cppyy
108       glib.out
109       glib.dev
110       libpcap
111       gtk3-x11.dev
112       harfbuzz
113       freetype
114       jansson
115     ];
117   propagatedBuildInputs = [ pythonEnv ];
119   preConfigure = ''
120      substituteInPlace src/tap-bridge/CMakeLists.txt \
121        --replace '-DTAP_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/' "-DTAP_CREATOR=\"$out/libexec/ns3/"
123     substituteInPlace src/fd-net-device/CMakeLists.txt \
124       --replace '-DRAW_SOCK_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DRAW_SOCK_CREATOR=\"$out/libexec/ns3/"
126     substituteInPlace src/fd-net-device/CMakeLists.txt \
127       --replace '-DTAP_DEV_CREATOR="''${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/' "-DTAP_DEV_CREATOR=\"$out/libexec/ns3/"
128   '';
130   doCheck = false;
132   buildTargets =
133     "build" + lib.optionalString enableDoxygen " doxygen" + lib.optionalString withManual "sphinx";
135   # to prevent fatal error: 'backward_warning.h' file not found
136   CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH";
138   # Make generated python bindings discoverable in customized python environment
139   passthru = {
140     pythonModule = python;
141   };
143   cmakeFlags = [
144     "-DPython3_LIBRARY_DIRS=${pythonEnv}/lib"
145     "-DPython3_INCLUDE_DIRS=${pythonEnv}/include"
146     "-DPython3_EXECUTABLE=${pythonEnv}/bin/python"
147     "-DNS3_PYTHON_BINDINGS=ON"
148     "-DNS3_DES_METRICS=ON"
149     "-DNS3_BINDINGS_INSTALL_DIR=${pythonEnv.sitePackages}"
150     "-DNS3_LOG=ON"
151     "-DNS3_ASSERT=ON"
152     "-DNS3_GTK3=ON"
153     "-DGTK3_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
154   ] ++ lib.optional doCheck "-DNS3_TESTS=ON";
156   # strictoverflow prevents clang from discovering pyembed when bindings
157   hardeningDisable = [
158     "fortify"
159     "strictoverflow"
160   ];
162   meta = with lib; {
163     homepage = "http://www.nsnam.org";
164     license = licenses.gpl3;
165     description = "Discrete time event network simulator";
166     platforms = with platforms; unix;
167     maintainers = with maintainers; [
168       teto
169       rgrunbla
170     ];
171     # never built on aarch64-darwin since first introduction in nixpkgs
172     broken =
173       (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
174       || (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
175   };