2017-11-07 11:58:08 +00:00
|
|
|
{ stdenv
|
2019-08-22 10:11:10 +01:00
|
|
|
, fetchFromGitLab
|
2021-01-16 16:23:50 +00:00
|
|
|
, fetchpatch
|
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
|
2020-10-28 15:15:05 +00:00
|
|
|
, modules ? [ "core" "network" "internet" "point-to-point" "point-to-point-layout" "fd-net-device" "netanim" ]
|
2017-11-07 11:58:08 +00:00
|
|
|
, lib
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pythonEnv = python.withPackages(ps:
|
2021-01-21 17:00:13 +00:00
|
|
|
lib.optional withManual ps.sphinx
|
|
|
|
++ 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";
|
2021-01-16 15:20:36 +00:00
|
|
|
version = "33";
|
2019-08-22 10:11:10 +01:00
|
|
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
owner = "nsnam";
|
|
|
|
repo = "ns-3-dev";
|
|
|
|
rev = "ns-3.${version}";
|
2021-01-16 16:23:50 +00:00
|
|
|
sha256 = "0ds8h0f2qcb0gc2a8bk38cbhdb122i4sbg589bjn59rblzw0hkq4";
|
2017-11-07 11:58:08 +00:00
|
|
|
};
|
|
|
|
|
2021-01-16 15:20:36 +00:00
|
|
|
nativeBuildInputs = [ wafHook python ];
|
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
|
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
wafConfigureFlags = with 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";
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
postBuild = with lib; let flags = concatStringsSep ";" (
|
2019-08-22 10:11:10 +01:00
|
|
|
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
|
|
|
'';
|
|
|
|
|
2021-01-16 16:23:50 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "upstream-issue-336.patch";
|
|
|
|
url = "https://gitlab.com/nsnam/ns-3-dev/-/commit/673004edae1112e6cb249b698aad856d728530fb.patch";
|
|
|
|
sha256 = "0q96ividinbh9xlws014b2ir6gaavygnln5ca9m1db06m4vfwhng";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2019-08-22 10:11:10 +01:00
|
|
|
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;
|
2021-01-16 15:20:36 +00:00
|
|
|
maintainers = with maintainers; [ teto rgrunbla ];
|
2017-11-07 11:58:08 +00:00
|
|
|
};
|
|
|
|
}
|