Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 177 lines 3.9 kB view raw
1{ 2 stdenv, 3 fetchFromGitLab, 4 python3, 5 libxml2, 6 sqlite, 7 8 boost, 9 gtk3-x11, 10 root, 11 glib, 12 gsl, 13 14 cmake, 15 pkg-config, 16 17 libpcap, 18 19 jansson, 20 21 harfbuzz, 22 freetype, 23 24 # for binding generation 25 castxml ? null, 26 cppyy ? null, 27 28 # can take a long time, generates > 30000 images/graphs 29 enableDoxygen ? false, 30 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, 42 43 # generates python bindings 44 pythonSupport ? true, 45 ncurses ? null, 46 47 lib, 48}: 49 50let 51 pythonEnv = python3.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 ); 63in 64stdenv.mkDerivation rec { 65 pname = "ns-3"; 66 version = "44"; 67 68 src = fetchFromGitLab { 69 owner = "nsnam"; 70 repo = "ns-3-dev"; 71 rev = "ns-3.${version}"; 72 hash = "sha256-rw/WAMk4ZitULqkdyEh9vAFp1UrD1tw2JqgxOT5JQ5I="; 73 }; 74 75 nativeBuildInputs = [ 76 cmake 77 pkg-config 78 pythonEnv 79 ]; 80 81 outputs = [ "out" ]; 82 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 ]; 116 117 propagatedBuildInputs = [ pythonEnv ]; 118 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/" 122 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/" 125 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 ''; 129 130 doCheck = false; 131 132 buildTargets = 133 "build" + lib.optionalString enableDoxygen " doxygen" + lib.optionalString withManual "sphinx"; 134 135 # to prevent fatal error: 'backward_warning.h' file not found 136 CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH"; 137 138 # Make generated python bindings discoverable in customized python environment 139 passthru = { 140 pythonModule = python3; 141 }; 142 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 ] 155 ++ lib.optional doCheck "-DNS3_TESTS=ON"; 156 157 # strictoverflow prevents clang from discovering pyembed when bindings 158 hardeningDisable = [ 159 "fortify" 160 "strictoverflow" 161 ]; 162 163 meta = with lib; { 164 homepage = "http://www.nsnam.org"; 165 license = licenses.gpl3; 166 description = "Discrete time event network simulator"; 167 platforms = with platforms; unix; 168 maintainers = with maintainers; [ 169 teto 170 rgrunbla 171 ]; 172 # never built on aarch64-darwin since first introduction in nixpkgs 173 broken = 174 (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) 175 || (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64); 176 }; 177}