From 44d2718c6525eb331a196e5b80f62cbead84b7d6 Mon Sep 17 00:00:00 2001 From: h1sk1 <44468142+h1sk1@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:12:37 +0000 Subject: [PATCH 1/3] feat: add devenv for compiling --- .envrc | 3 + .gitignore | 9 +++ build.sbt | 2 +- devenv.lock | 116 +++++++++++++++++++++++++++++++++++++++ devenv.nix | 19 +++++++ devenv.yaml | 15 +++++ project/build.properties | 2 +- 7 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 .envrc create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..5bf8fc159 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=" + +use devenv \ No newline at end of file diff --git a/.gitignore b/.gitignore index 88b53f3c4..6dff93878 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,12 @@ src/test/**/.DS_Store .bloop/ .ammonite/ project/metals.sbt +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/build.sbt b/build.sbt index 955fd766c..1bf002291 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ enablePlugins(sbtdocker.DockerPlugin, JavaServerAppPackaging, JDebPackaging, Sys name := "vsys" organization := "systems.v" version := "0.4.2" -scalaVersion in ThisBuild := "2.12.6" +scalaVersion in ThisBuild := "2.12.18" crossPaths := false publishArtifact in (Compile, packageDoc) := false publishArtifact in (Compile, packageSrc) := false diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 000000000..a7cb6e18d --- /dev/null +++ b/devenv.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1728452860, + "owner": "cachix", + "repo": "devenv", + "rev": "e7a0bc559f5a66aaa42f5028db6162c4dd4587eb", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1728328465, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1bfbbbe5bbf888d675397c66bfdb275d0b99361c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1728092656, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "1211305a5b237771e13fcca0c51e60ad47326a9a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 000000000..7722688cc --- /dev/null +++ b/devenv.nix @@ -0,0 +1,19 @@ +{ 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; + + packages = [ pkgs.curl pkgs.git ]; + + processes = { + sbt-package.exec = "sbt packageAll; exit"; + }; + + enterShell = '' + echo "SBT environment" + ''; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 000000000..116a2adb3 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/project/build.properties b/project/build.properties index 31334bbd3..04267b14a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.1 +sbt.version=1.9.9 From 26ac3a2b0be36104c48b260ea9aef076c7438d79 Mon Sep 17 00:00:00 2001 From: h1sk1 <44468142+h1sk1@users.noreply.github.com> Date: Sat, 12 Oct 2024 09:44:08 +0000 Subject: [PATCH 2/3] refactor: update devenv file for better building --- ] | 41 +++++++++++++++++++++++++++++++++++++++ devenv.nix | 56 ++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 ] diff --git a/] b/] new file mode 100644 index 000000000..c187c01c0 --- /dev/null +++ b/] @@ -0,0 +1,41 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + languages.scala.enable = true; + languages.scala.sbt.enable = true; + + packages = [ pkgs.curl pkgs.git pkgs.jdk21 pkgs.scala pkgs.sbt ]; + + env = { + VSYS_JAR_FILE = "./target/vsys-all-0.4.2.jar"; + VSYS_CONF_FILE = "./vsys-mainnet.conf"; + }; + + processes = { + build.exec = '' + if [ ! -e "$VSYS_JAR_FILE" ]; then + sbt packageAll + else echo "Jar file already exists, skipping build..."; + fi''; + + run.exec = '' + while [ ! -e "$VSYS_JAR_FILE" ]; do + echo -ne "\rWaiting for jar file to be built..."; + sleep 5; + done; + + 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; + echo -ne "\rFailed to start VSYS node, retrying..."; + sleep 5; + done''; + }; + + enterShell = '' + echo "SBT environment" + ''; +} diff --git a/devenv.nix b/devenv.nix index 7722688cc..d39932046 100644 --- a/devenv.nix +++ b/devenv.nix @@ -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" + ''; } From cf29398e4b4ef391e7d6b362c2483f80e2e66ae1 Mon Sep 17 00:00:00 2001 From: h1sk1 <44468142+h1sk1@users.noreply.github.com> Date: Sat, 12 Oct 2024 09:47:41 +0000 Subject: [PATCH 3/3] fix: remove redundant files --- ] | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 ] diff --git a/] b/] deleted file mode 100644 index c187c01c0..000000000 --- a/] +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs, lib, config, inputs, ... }: - -{ - languages.scala.enable = true; - languages.scala.sbt.enable = true; - - packages = [ pkgs.curl pkgs.git pkgs.jdk21 pkgs.scala pkgs.sbt ]; - - env = { - VSYS_JAR_FILE = "./target/vsys-all-0.4.2.jar"; - VSYS_CONF_FILE = "./vsys-mainnet.conf"; - }; - - processes = { - build.exec = '' - if [ ! -e "$VSYS_JAR_FILE" ]; then - sbt packageAll - else echo "Jar file already exists, skipping build..."; - fi''; - - run.exec = '' - while [ ! -e "$VSYS_JAR_FILE" ]; do - echo -ne "\rWaiting for jar file to be built..."; - sleep 5; - done; - - 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; - echo -ne "\rFailed to start VSYS node, retrying..."; - sleep 5; - done''; - }; - - enterShell = '' - echo "SBT environment" - ''; -}