update Hash2Pub testbed container and make it more configurable

This commit is contained in:
Trolli Schmittlauch 2020-10-09 01:20:40 +02:00
parent 231d81043e
commit f1da50c5c0
2 changed files with 40 additions and 19 deletions

View file

@ -1,10 +1,20 @@
{ config, pkgs, ... }:
{ config, pkgs, experimentUid ? 1000, ... }:
let
projectDir = "/home/spiollinux/Seafile/Studium/Semester11/INF-PM-FP-ANW";
projectPath = builtins.toPath projectDir;
projectMount = "/mnt/project";
shell = import (projectDir + "/Hash2Pub/shell.nix");
shell = (import (projectDir + "/Hash2Pub/default.nix") {}).shell;
simulationSetupScript = pkgs.writeShellScriptBin "simulationSetup" ''
# make cabal-install work offline
mkdir $HOME/.cabal
echo "" > $HOME/.cabal/config
# run simulation script within the shell
${pkgs.nix}/bin/nix-shell ${shell.drvPath} --command "cd ${projectMount} && bash ./build/simulationrunner.sh 2>&1"
'';
instanceData = builtins.fromJSON (builtins.readFile "${projectDir}/simulationData/inputs/generated/instances_sample.json");
in
{
@ -17,30 +27,36 @@ in
config = {
networking = {
firewall.enable = false;
interfaces.lo.ipv6.addresses = [
{address = "2604:a880:800:10::34e1:d001"; prefixLength = 0;}
{address = "2001:41d0:2:c0af::15"; prefixLength = 0;}
{address = "2a01:e0a:23a:5600::2"; prefixLength = 64;}
];
extraHosts = ''
2604:a880:800:10::34e1:d001 animalliberation.social
2001:41d0:2:c0af::15 hostux.social
2a01:e0a:23a:5600::2 social.imirhil.fr
'';
interfaces.lo.ipv6.addresses =
builtins.map (inst: {address = inst.ip; prefixLength = 0;}) instanceData;
extraHosts =
pkgs.lib.concatMapStringsSep "\n" (inst: "${inst.ip} ${inst.hostname}") instanceData;
};
# avoid permission problems with project builds
users.users.experimentor = {
uid = experimentUid;
isNormalUser = true;
};
# adjust open file limits
security.pam.loginLimits = [{
domain = "*"
; type = "-"
; item = "nofile"
; value = "50000"
;}];
environment.systemPackages = [
pkgs.netcat
pkgs.iproute
pkgs.tmux
pkgs.ping
pkgs.lsof
pkgs.iftop
(pkgs.writeShellScriptBin "doSimulation" ''
# make cabal-install work offline
mkdir $HOME/.cabal
echo "" > $HOME/.cabal/config
# run simulation script within the shell
${pkgs.nix}/bin/nix-shell ${shell.drvPath} --command "cd ${projectMount} && bash simtest.sh"
su experimentor -c "${simulationSetupScript}/bin/simulationSetup"
'')
pkgs.tcpdump
];
};
}

View file

@ -198,7 +198,12 @@ in
# declarative containers
containers = {
hash2PubSim = import ./Hash2PubTestbed.nix {inherit pkgs config;};
hash2PubSim = import ./Hash2PubTestbed.nix
{
inherit pkgs config;
experimentUid = config.users.users.spiollinux.uid;
projectDir = "/home/spiollinux/Seafile/Studium/Semester11/INF-PM-FP-ANW";
};
};
# stop NetworkManager from managing virtual interfaces