Skip to content

Commit

Permalink
sumo, omnetpp: init (FIXME)
Browse files Browse the repository at this point in the history
  • Loading branch information
timokau committed Dec 12, 2019
1 parent 371a565 commit 4ea8e69
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 0 deletions.
135 changes: 135 additions & 0 deletions pkgs/applications/networking/omnetpp/default.nix
@@ -0,0 +1,135 @@
{ stdenv
, lib
, fetchurl
, autoreconfHook
, tcl
, tk
, jre
, bison
, flex
, perl
, which
, xdg_utils
, logger
, python2
, libxml2
}:

stdenv.mkDerivation rec {
pname = "omnetpp";
version = "5.4.1";
name = "${pname}-${version}";

# Distributed via ipfs. Since the current `fetchipfs` doesn't support ipns,
# we use the official http gateway with `fetchurl` instead.
src = fetchurl {
# url = "https://ipfs.omnetpp.org/release/omnetpp-${version}-src-linux.tgz";
url = "https://ipfs.omnetpp.org/release/omnetpp-${version}-src-core.tgz";
sha256 = "1bakrhzr4s25a8yxcfkwgf23n34ykpw02zkjccrnwwmz7a5izp6n";
};

# should really be postUnpack, but by that time we haven't cd'd into the unpacked directory yet
# build in $out since there is no `make install` and the build process will leave references to the path it was built in
preAutoreconf = ''
mkdir -p "$out"
cp -r * "$out"
cd "$out" # since there is no `make install`, build at the target
'';

# for reference: https://omnetpp.org/doc/omnetpp/InstallGuide.pdf
preConfigure = ''
source setenv -f # set needed environment variables
mkdir home
export HOME="$PWD/home"
export LIBXML_LIBS='-L${libxml2.dev}/lib -lxml2'
export LIBXML_CFLAGS='-I${libxml2.dev}/include/libxml2'
'';

buildFlags = [
# "cleanall" # force rebuild
# Build shared library. This isn't done by default since it is distributed in binary form for convenience. We re-build it.
# "ui"
"all"
];

# https://groups.google.com/forum/#!topic/omnetpp/vezyKEe8Qek
postFixup = ''
echo 'echo "The omnet++ IDE is currently not packaged for Nix."'
'';

doCheck = true; # although no acutal checks are present

patches = [
# configure checks for perl to be in /usr/bin/perl because that is needed for shebangs to work
# since we patch shebangs, that is not necessary
./patches/0001-Don-t-check-for-perl-in-a-specific-location.patch
# ./patches/0002-Debug.patch # FIXME
];

postPatch = ''
substituteInPlace configure.user --replace 'WITH_QTENV=yes' 'WITH_QTENV=no' # FIXME
substituteInPlace configure.user --replace 'WITH_OSG=yes' 'WITH_OSG=no' # FIXME
substituteInPlace configure.user --replace 'WITH_OSGEARTH=yes' 'WITH_OSG=no' # FIXME
# replace error.log file (not writeable) with syslog
for file in src/utils/omnest src/utils/omnetpp; do
substituteInPlace "$file" \
--replace '2>$IDEDIR/error.log' '2>&1 >/dev/null | ${logger}/bin/logger -p user.err -t omnetpp'
done
mkdir -p "$out/ide"
echo 'This is a stub. See the syslog (tag omnetpp) for the logs.' > "$out/ide/error.log"
substituteInPlace src/utils/omnest --replace 'WITH_OSGEARTH=yes' 'WITH_OSG=no' # FIXME
echo 'ARFLAG_OUT="-r "' >> configure.user
patchShebangs .
'';

# make install-menu-item
# make install-desktop-icon

nativeBuildInputs = [
autoreconfHook
];

buildInputs = [
tcl
tk
jre
bison
flex
perl
which
xdg_utils # for make install-desktop-icon
python2
libxml2
];

checkPhase = ''
export PATH="$out/bin:$PATH"
cd "$out/test"
# only test core functionality since IDE is not built
make test_core
'';

installPhase = ''
# actual "installation" happens during build since there is no `make install`
rm -r $out/test # not necessary
echo '#! /bin/sh' > "$out/bin/omnetpp" # override default executable that isn't working
echo ' echo "The omnet++ IDE is not currently packaged for Nix."' >> "$out/bin/omnetpp"
'';

enableParallelBuilding = true;

meta = with lib; {
description = ""; # FIXME
license = {
# free for non-commercial simulations like at academic institutions and for teaching
fullName = "Academic Public License";
url = https://omnetpp.org/intro/license;
};
maintainers = with maintainers; [ timokau ];
platforms = platforms.linux;
};
}
@@ -0,0 +1,27 @@
From 3f9d327dbdb2b45563317df3350fc93fe7a66ed6 Mon Sep 17 00:00:00 2001
From: Timo Kaufmann <timokau@zoho.com>
Date: Fri, 5 Oct 2018 11:37:23 +0200
Subject: [PATCH 1/2] Don't check for perl in a specific location

---
configure.in | 4 ----
1 file changed, 4 deletions(-)

diff --git a/configure.in b/configure.in
index d05da25..54f66dc 100644
--- a/configure.in
+++ b/configure.in
@@ -697,10 +697,6 @@ if test "$PERL" = "not found"; then
OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES perl"
AC_MSG_WARN(Perl not found -- please install it! Perl is required by opp_makemake and some other programs.)
fi
-if test ! -x /usr/bin/perl; then
- this_perl=`which perl`
- AC_MSG_ERROR(Perl MUST be available as /usr/bin/perl. Creating a soft link should help: ln -s $this_perl /usr/bin/perl)
-fi

# swig is used for building the ui support libs
AC_ARG_VAR(SWIG, The Swig interface generator)
--
2.18.0

40 changes: 40 additions & 0 deletions pkgs/applications/networking/omnetpp/patches/0002-Debug.patch
@@ -0,0 +1,40 @@
From c632045bd0d78e4720c06be89759bf7efe6ea6ab Mon Sep 17 00:00:00 2001
From: Timo Kaufmann <timokau@zoho.com>
Date: Fri, 5 Oct 2018 12:05:32 +0200
Subject: [PATCH 2/2] Debug

---
src/envir/Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/envir/Makefile b/src/envir/Makefile
index 4ef4402..4a43fca 100644
--- a/src/envir/Makefile
+++ b/src/envir/Makefile
@@ -100,17 +100,17 @@ else
# statically linked library (on all platforms)
$O/%$(A_LIB_SUFFIX) : $(OBJS)
@mkdir -p $O
- @echo Creating static library: $@
- $(Q)$(AR) $(ARFLAG_OUT)$O/$(LIBNAME)$(A_LIB_SUFFIX) $(OBJS)
- $(Q)$(RANLIB) $O/$(LIBNAME)$(A_LIB_SUFFIX)
+ @echo Creating static library1: $@
+ @echo $(Q)$(AR) $(ARFLAG_OUT)$O/$(LIBNAME)$(A_LIB_SUFFIX) $(OBJS)
+ @echo $(Q)$(RANLIB) $O/$(LIBNAME)$(A_LIB_SUFFIX)
endif

# Build a static lib that contains the main() function used with executable or dynamically linked models
$O/$(MAINLIBNAME)$(A_LIB_SUFFIX) : $O/main.o
@mkdir -p $O
- @echo Creating static library: $@
- $(Q)$(AR) $(ARFLAG_OUT)$O/$(MAINLIBNAME)$(A_LIB_SUFFIX) $O/main.o
- $(Q)$(RANLIB) $O/$(MAINLIBNAME)$(A_LIB_SUFFIX)
+ @echo Creating static library2: $@
+ @echo $(Q)$(AR) $(ARFLAG_OUT)$O/$(MAINLIBNAME)$(A_LIB_SUFFIX) $O/main.o
+ @echo $(Q)$(RANLIB) $O/$(MAINLIBNAME)$(A_LIB_SUFFIX)

# build opp_run executable

--
2.18.0

98 changes: 98 additions & 0 deletions pkgs/applications/networking/sumo/default.nix
@@ -0,0 +1,98 @@
{ stdenv
, lib
, fetchFromGitHub
, autoreconfHook
, pkgconfig
, fox_1_6
, xercesc
, proj
, gdal
, libX11
, mesa
, libGLU
, lzma
, libjpeg
, poppler
, qhull
, hdf5
, hdf4
, curl
, libtiff
, sqlite
, python2
, ffmpeg ? null
, withVideo ? true # ffmpeg for video output support
}:

stdenv.mkDerivation rec {
name = "sumo-${version}";
version = "1.0.1";

# For reference: http://sumo.dlr.de/wiki/Installing/Linux_Build
src = fetchFromGitHub {
owner = "eclipse";
repo = "sumo";
rev = "v${ lib.replaceStrings [ "." ] [ "_" ] version }";
sha256 = "0mdn88lnimhy8ydm2cbglxi08jafik3msndcg9ml3saz1v6858qf";
};

postPatch = ''
patchShebangs .
'';

preBuild = ''
export SUMO_HOME="$PWD"
'';

nativeBuildInputs = [
autoreconfHook
pkgconfig # for some reason needed for autoreconf
];

buildInputs = [
fox_1_6
xercesc
proj
gdal
libX11
ffmpeg
mesa
libGLU
lzma
libjpeg
poppler
qhull
hdf4
hdf5
curl
libtiff
sqlite
python2
] ++ lib.optionals withVideo [
ffmpeg
];

NIX_CFLAGS_COMPILE = "-fpermissive"; # invalid conversions to FX::FXObject

enableParallelBuilding = true;

# Tests need texttest, which is not packaged. See
# https://github.com/eclipse/sumo/blob/master/tests/README_Tests.md
# https://github.com/eclipse/sumo/blob/master/tests/runTests.sh
doCheck = false;

# sanity checks
doInstallCheck = true;
installCheckPhase = ''
"$out/bin/sumo" --help || exit 1
"$out/bin/sumo" --version | grep '${version}' || exit 1
'';

meta = with lib; {
description = "Simulation of Urban MObility";
homepage = http://sumo.dlr.de/;
license = licenses.epl20;
maintainers = with maintainers; [ timokau ];
platforms = platforms.linux;
};
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -950,6 +950,10 @@ with pkgs;

libqmatrixclient = libsForQt5.callPackage ../development/libraries/libqmatrixclient { };

omnetpp = callPackage ../applications/networking/omnetpp { };

sumo = callPackage ../applications/networking/sumo { };

quaternion = libsForQt5.callPackage ../applications/networking/instant-messengers/quaternion { };

tensor = libsForQt5.callPackage ../applications/networking/instant-messengers/tensor { };
Expand Down

0 comments on commit 4ea8e69

Please sign in to comment.