From 58a46e3b0a031f4d1ed4754158149a59173b61fa Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Fri, 11 Feb 2022 09:28:03 -0700 Subject: [PATCH] add piston nix pkg for jvm-kotlin --- packages/kotlin/1.4.31/build.sh | 13 ---------- packages/kotlin/1.4.31/compile | 6 ----- packages/kotlin/1.4.31/environment | 4 --- packages/kotlin/1.4.31/metadata.json | 5 ---- packages/kotlin/1.4.31/run | 5 ---- packages/kotlin/1.4.31/test.kt | 3 --- runtimes/default.nix | 1 + runtimes/jvm-kotlin.nix | 39 ++++++++++++++++++++++++++++ 8 files changed, 40 insertions(+), 36 deletions(-) delete mode 100755 packages/kotlin/1.4.31/build.sh delete mode 100644 packages/kotlin/1.4.31/compile delete mode 100644 packages/kotlin/1.4.31/environment delete mode 100644 packages/kotlin/1.4.31/metadata.json delete mode 100644 packages/kotlin/1.4.31/run delete mode 100644 packages/kotlin/1.4.31/test.kt create mode 100644 runtimes/jvm-kotlin.nix diff --git a/packages/kotlin/1.4.31/build.sh b/packages/kotlin/1.4.31/build.sh deleted file mode 100755 index c00cb27..0000000 --- a/packages/kotlin/1.4.31/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# Download and extract JDK8 -curl -L "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz" -o jdk.tar.gz -tar xzf jdk.tar.gz --strip-components=1 -rm jdk.tar.gz - -# Download and extract Kotlin -curl -L "https://github.com/JetBrains/kotlin/releases/download/v1.4.31/kotlin-compiler-1.4.31.zip" -o kotlin.zip -unzip kotlin.zip -rm kotlin.zip -cp -r kotlinc/* . -rm -rf kotlinc diff --git a/packages/kotlin/1.4.31/compile b/packages/kotlin/1.4.31/compile deleted file mode 100644 index 9b49562..0000000 --- a/packages/kotlin/1.4.31/compile +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -rename 's/$/\.kt/' "$@" # Add .kt extension - -# Compile Kotlin code to a jar file -kotlinc *.kt -include-runtime -d code.jar diff --git a/packages/kotlin/1.4.31/environment b/packages/kotlin/1.4.31/environment deleted file mode 100644 index aadd2e5..0000000 --- a/packages/kotlin/1.4.31/environment +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Add java and kotlinc to path -export PATH=$PWD/bin:$PATH diff --git a/packages/kotlin/1.4.31/metadata.json b/packages/kotlin/1.4.31/metadata.json deleted file mode 100644 index 304c5cd..0000000 --- a/packages/kotlin/1.4.31/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "kotlin", - "version": "1.4.31", - "aliases": ["kt"] -} diff --git a/packages/kotlin/1.4.31/run b/packages/kotlin/1.4.31/run deleted file mode 100644 index 8ecc073..0000000 --- a/packages/kotlin/1.4.31/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -# Run jar file -shift -java -jar code.jar "$@" diff --git a/packages/kotlin/1.4.31/test.kt b/packages/kotlin/1.4.31/test.kt deleted file mode 100644 index 0c9540f..0000000 --- a/packages/kotlin/1.4.31/test.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - println("OK") -} diff --git a/runtimes/default.nix b/runtimes/default.nix index 3b25c62..4e41dde 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -37,4 +37,5 @@ args: { "lua" = import ./lua.nix args; "lolcode" = import ./lolcode.nix args; "sbcl-lisp" = import ./sbcl-lisp.nix args; + "jvm-kotlin" = import ./jvm-kotlin.nix args; } diff --git a/runtimes/jvm-kotlin.nix b/runtimes/jvm-kotlin.nix new file mode 100644 index 0000000..62e402b --- /dev/null +++ b/runtimes/jvm-kotlin.nix @@ -0,0 +1,39 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.kotlin; + jre = pkgs.jre; +in piston.mkRuntime { + language = "kotlin"; + version = pkg.version; + runtime = "jvm"; + + aliases = [ + "kt" + ]; + + compile = '' + rename 's/$/\.kt/' "$@" # Add .kt extension + ${pkg}/bin/kotlinc *.kt -include-runtime -d code.jar + ''; + + run = '' + shift + ${jre}/bin/java -jar code.jar "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.kt" = '' + fun main() { + println("OK") + } + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.kt"; + }) + ]; +} \ No newline at end of file