2024-03-16 17:18:20 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
experimentUid ? 1000,
|
|
|
|
...
|
|
|
|
}:
|
2020-07-26 00:34:08 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
projectDir = "/home/spiollinux/Seafile/Studium/Semester11/INF-PM-FP-ANW";
|
|
|
|
projectPath = builtins.toPath projectDir;
|
|
|
|
projectMount = "/mnt/project";
|
2024-03-16 17:18:20 +01:00
|
|
|
shell = (import (projectDir + "/Hash2Pub/default.nix") { }).shell;
|
2020-10-09 01:20:40 +02:00
|
|
|
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"
|
2024-03-16 17:18:20 +01:00
|
|
|
'';
|
|
|
|
instanceData = builtins.fromJSON (
|
|
|
|
builtins.readFile "${projectDir}/simulationData/inputs/generated/instances_sample.json"
|
|
|
|
);
|
2020-07-26 00:34:08 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
privateNetwork = true;
|
|
|
|
ephemeral = true;
|
|
|
|
bindMounts = {
|
2024-03-16 17:18:20 +01:00
|
|
|
"${projectMount}" = {
|
|
|
|
hostPath = projectDir;
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
2020-07-26 00:34:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
networking = {
|
|
|
|
firewall.enable = false;
|
2024-03-16 17:18:20 +01:00
|
|
|
interfaces.lo.ipv6.addresses = builtins.map (inst: {
|
|
|
|
address = inst.ip;
|
|
|
|
prefixLength = 0;
|
|
|
|
}) instanceData;
|
|
|
|
extraHosts = pkgs.lib.concatMapStringsSep "\n" (inst: "${inst.ip} ${inst.hostname}") instanceData;
|
2020-10-09 01:20:40 +02:00
|
|
|
};
|
|
|
|
# avoid permission problems with project builds
|
|
|
|
users.users.experimentor = {
|
|
|
|
uid = experimentUid;
|
|
|
|
isNormalUser = true;
|
2020-07-26 00:34:08 +02:00
|
|
|
};
|
2020-10-09 01:20:40 +02:00
|
|
|
|
|
|
|
# adjust open file limits
|
2024-03-16 17:18:20 +01:00
|
|
|
security.pam.loginLimits = [
|
|
|
|
{
|
|
|
|
domain = "*";
|
|
|
|
type = "-";
|
|
|
|
item = "nofile";
|
|
|
|
value = "50000";
|
|
|
|
}
|
|
|
|
];
|
2020-10-09 01:20:40 +02:00
|
|
|
|
2020-07-26 00:34:08 +02:00
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.netcat
|
|
|
|
pkgs.iproute
|
|
|
|
pkgs.tmux
|
|
|
|
pkgs.ping
|
2020-10-09 01:20:40 +02:00
|
|
|
pkgs.lsof
|
|
|
|
pkgs.iftop
|
2020-07-26 00:34:08 +02:00
|
|
|
(pkgs.writeShellScriptBin "doSimulation" ''
|
2020-10-09 01:20:40 +02:00
|
|
|
su experimentor -c "${simulationSetupScript}/bin/simulationSetup"
|
2024-03-16 17:18:20 +01:00
|
|
|
'')
|
2020-10-09 01:20:40 +02:00
|
|
|
pkgs.tcpdump
|
2020-07-26 00:34:08 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|