Skip to content

Commit

Permalink
Support devenv up (#324)
Browse files Browse the repository at this point in the history
* refactor: update devenv file for better building
* fix: remove redundant files
  • Loading branch information
h1sk1 authored Oct 18, 2024
1 parent e13fd68 commit 85c05d4
Showing 1 changed file with 44 additions and 12 deletions.
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"
'';
}

0 comments on commit 85c05d4

Please sign in to comment.