Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support devenv up #324

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
{ pkgs, lib, config, inputs, ... }:

{
languages.java.jdk.package = pkgs.jdk21;
languages.scala.package = pkgs.scala;
languages.scala.enable = true;
languages.scala.sbt.package = pkgs.sbt;
languages.scala.sbt.enable = true;
languages.scala.enable = true;
languages.scala.sbt.enable = true;

packages = [ pkgs.curl pkgs.git ];
packages = [ pkgs.curl pkgs.git pkgs.jdk21 pkgs.scala pkgs.sbt ];

processes = {
sbt-package.exec = "sbt packageAll; exit";
};
env = {
VSYS_JAR_FILE = "./target/vsys-all-0.4.2.jar";
VSYS_CONF_FILE = "./vsys-mainnet.conf";
};

enterShell = ''
echo "SBT environment"
'';
processes = {
build.exec = ''
if [ ! -e "$VSYS_JAR_FILE" ]; then
sbt packageAll
else echo "Jar file already exists, skipping build...";
fi'';

run.exec = ''
echo "Waiting for jar file to be built...";
while [ ! -e "$VSYS_JAR_FILE" ]; do
sleep 1;
done;
sleep 5;

echo "Starting VSYS node...";
for attempt in seq 1 5; do
java -jar $VSYS_JAR_FILE $VSYS_CONF_FILE;
if [ $? -eq 0 ]; then
break;
fi;

if [ $attempt -eq 1 ]; then
echo "Failed to start VSYS node, retrying...";
fi;

if [ $attempt -eq 5 ]; then
echo "Failed to start VSYS node, exiting...";
exit 1;
fi;

sleep 5;
done'';
};

enterShell = ''
echo "SBT environment"
'';
}
Loading