2017-11-07 11:58:08 +00:00
|
|
|
{ stdenv
|
2019-08-22 10:11:10 +01:00
|
|
|
, fetchFromGitLab
|
2017-11-07 11:58:08 +00:00
|
|
|
, python
|
2018-11-11 21:20:41 +00:00
|
|
|
, wafHook
|
2017-11-07 11:58:08 +00:00
|
|
|
|
|
|
|
# for binding generation
|
|
|
|
, castxml ? null
|
|
|
|
|
|
|
|
# can take a long time, generates > 30000 images/graphs
|
|
|
|
, enableDoxygen ? false
|
|
|
|
|
|
|
|
# e.g. "optimized" or "debug". If not set, use default one
|
|
|
|
, build_profile ? null
|
|
|
|
|
|
|
|
# --enable-examples
|
|
|
|
, withExamples ? 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, texlive ? null
|
|
|
|
|
|
|
|
# generates python bindings
|
2019-08-22 10:11:10 +01:00
|
|
|
, pythonSupport ? false, ncurses ? null
|
2017-11-07 11:58:08 +00:00
|
|
|
|
|
|
|
# All modules can be enabled by choosing 'all_modules'.
|
|
|
|
# we include here the DCE mandatory ones
|
|
|
|
, modules ? [ "core" "network" "internet" "point-to-point" "fd-net-device" "netanim"]
|
|
|
|
, lib
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pythonEnv = python.withPackages(ps:
|
|
|
|
stdenv.lib.optional withManual ps.sphinx
|
2019-08-22 10:11:10 +01:00
|
|
|
++ stdenv.lib.optionals pythonSupport (with ps;[ pybindgen pygccxml ])
|
2017-11-07 11:58:08 +00:00
|
|
|
);
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-22 10:11:10 +01:00
|
|
|
pname = "ns-3";
|
|
|
|
version = "30";
|
|
|
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
owner = "nsnam";
|
|
|
|
repo = "ns-3-dev";
|
|
|
|
rev = "ns-3.${version}";
|
|
|
|
sha256 = "0smdi3gglmafpc7a20hj2lbmwks3d5fpsicpn39lmm3svazw0bvp";
|
2017-11-07 11:58:08 +00:00
|
|
|
};
|
|
|
|
|
2018-11-11 21:20:41 +00:00
|
|
|
nativeBuildInputs = [ wafHook ];
|
2019-08-22 10:11:10 +01:00
|
|
|
|
|
|
|
outputs = [ "out" ] ++ lib.optional pythonSupport "py";
|
|
|
|
|
2017-11-07 11:58:08 +00:00
|
|
|
# ncurses is a hidden dependency of waf when checking python
|
2019-08-22 10:11:10 +01:00
|
|
|
buildInputs = lib.optionals pythonSupport [ castxml ncurses ]
|
|
|
|
++ lib.optional enableDoxygen [ doxygen graphviz imagemagick ]
|
|
|
|
++ lib.optional withManual [ dia tetex ghostscript texlive.combined.scheme-medium ];
|
2017-11-07 11:58:08 +00:00
|
|
|
|
2019-08-22 10:11:10 +01:00
|
|
|
propagatedBuildInputs = [ pythonEnv ];
|
2017-11-07 11:58:08 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs doc/ns3_html_theme/get_version.sh
|
|
|
|
'';
|
|
|
|
|
2019-04-10 04:44:37 +01:00
|
|
|
wafConfigureFlags = with stdenv.lib; [
|
2019-08-22 10:11:10 +01:00
|
|
|
"--enable-modules=${concatStringsSep "," modules}"
|
2017-11-07 11:58:08 +00:00
|
|
|
"--with-python=${pythonEnv.interpreter}"
|
|
|
|
]
|
|
|
|
++ optional (build_profile != null) "--build-profile=${build_profile}"
|
|
|
|
++ optional withExamples " --enable-examples "
|
|
|
|
++ optional doCheck " --enable-tests "
|
|
|
|
;
|
|
|
|
|
2019-08-22 10:11:10 +01:00
|
|
|
doCheck = true;
|
|
|
|
|
2018-11-11 21:20:41 +00:00
|
|
|
buildTargets = "build"
|
|
|
|
+ lib.optionalString enableDoxygen " doxygen"
|
|
|
|
+ lib.optionalString withManual "sphinx";
|
2017-11-07 11:58:08 +00:00
|
|
|
|
2019-08-22 10:11:10 +01:00
|
|
|
# to prevent fatal error: 'backward_warning.h' file not found
|
|
|
|
CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH";
|
|
|
|
|
|
|
|
postBuild = with stdenv.lib; let flags = concatStringsSep ";" (
|
|
|
|
optional enableDoxygen "./waf doxygen"
|
|
|
|
++ optional withManual "./waf sphinx"
|
|
|
|
);
|
|
|
|
in "${flags}"
|
|
|
|
;
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput "${pythonEnv.libPrefix}" "$py"
|
|
|
|
'';
|
2017-11-07 11:58:08 +00:00
|
|
|
|
|
|
|
# we need to specify the proper interpreter else ns3 can check against a
|
2019-08-22 10:11:10 +01:00
|
|
|
# different version
|
2017-11-07 11:58:08 +00:00
|
|
|
checkPhase = ''
|
2019-08-22 10:11:10 +01:00
|
|
|
${pythonEnv.interpreter} ./test.py --nowaf
|
2017-11-07 11:58:08 +00:00
|
|
|
'';
|
|
|
|
|
2019-08-22 10:11:10 +01:00
|
|
|
# strictoverflow prevents clang from discovering pyembed when bindings
|
|
|
|
hardeningDisable = [ "fortify" "strictoverflow"];
|
2018-05-30 03:37:16 +01:00
|
|
|
|
2019-08-22 10:11:10 +01:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = "http://www.nsnam.org";
|
|
|
|
license = licenses.gpl3;
|
2017-11-07 11:58:08 +00:00
|
|
|
description = "A discrete time event network simulator";
|
2019-08-22 10:11:10 +01:00
|
|
|
platforms = with platforms; unix;
|
|
|
|
maintainers = with maintainers; [ teto ];
|
2017-11-07 11:58:08 +00:00
|
|
|
};
|
|
|
|
}
|