From d33e47e60ad1e5863458a191cf7b66964d8c8543 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Mon, 2 May 2022 21:16:25 +0200 Subject: [PATCH 1/7] Fix runtime finding in v2 endpoint --- api/src/api/v2.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 6cf2106..725f0a3 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -50,6 +50,7 @@ const SIGNALS = [ function get_job(job_info, available_runtimes) { let { language, + version, args, stdin, files, @@ -79,8 +80,10 @@ function get_job(job_info, available_runtimes) { } } - const rt = available_runtimes.find(rt => - [...rt.aliases, rt.language].includes(rt.language) + const rt = available_runtimes.find( + rt => + [...rt.aliases, rt.language].includes(language) && + (version === rt.version || version === '*') ); if (rt === undefined) { From 4470eb637f8acc53c60f91736cb96e3835dbfb31 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sat, 4 Jun 2022 22:27:32 +0200 Subject: [PATCH 2/7] Add priorities, modify scaffold.sh --- runtimes/priorities/default.nix | 66 +++++++++++++++++++++++++++++++++ runtimes/scaffold.sh | 8 +++- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 runtimes/priorities/default.nix diff --git a/runtimes/priorities/default.nix b/runtimes/priorities/default.nix new file mode 100644 index 0000000..128310a --- /dev/null +++ b/runtimes/priorities/default.nix @@ -0,0 +1,66 @@ +[ + "node-javascript" + "python2" + "python3" + "bash" + "clojure" + "cobol-gnu-cobol" + "crystal" + "dart" + "dash" + "deno-javascript" + "deno-typescript" + "elixir" + "erlang" + "gawk-awk" + "openjdk11_headless-java" + "ruby" + "zig" + "vlang" + "swift" + "node-typescript" + "sqlite" + "rscript" + "raku" + "racket" + "powershell" + "prolog" + "ponylang" + "php" + "perl" + "octave" + "ocaml" + "nim" + "nasm" + "nasm-nasm64" + "mono-csharp" + "lua" + "lolcode" + "sbcl-lisp" + "jvm-kotlin" + "julia" + "jelly" + "openjdk-java" + "iverilog" + "ghc-haskell" + "groovy" + "go" + "gcc-c" + "gcc-c++" + "gcc-d" + "gcc-fortran" + "yabasic" + "emacs" + "gnat-ada" + "rust" + "dotnet-sdk-csharp" + "dotnet-sdk-fsharp" + "dotnet-sdk-fsharp-interactive" + "dotnet-sdk-visual-basic" + "fpc-pascal" + "brainfuck" + "node-coffeescript" + "jvm-scala" + "llvm_ir" + "mono-basic" +] diff --git a/runtimes/scaffold.sh b/runtimes/scaffold.sh index 2a49ef2..11bf5a6 100755 --- a/runtimes/scaffold.sh +++ b/runtimes/scaffold.sh @@ -32,9 +32,13 @@ else .scaffold.nix > $NAME.nix echo "}" >> default.nix - git add $NAME.nix default.nix + sed -i '$d' ./priorities/default.nix + echo " \"$NAME\"" >> ./priorities/default.nix + echo "]" >> ./priorities/default.nix + + git add $NAME.nix default.nix ./priorities echo "Scaffolded $NAME" echo "Edit $NAME.nix to get started" echo "Once you are done, run ./piston test $NAME to test it" -fi \ No newline at end of file +fi From b50af1378780b7a6c305e288743366088544d535 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sat, 4 Jun 2022 23:14:11 +0200 Subject: [PATCH 3/7] Implement runtime priorities --- api/src/bin/pistond.js | 17 ++++++++++++++++- flake.nix | 1 + runtimes/priorities/default.nix | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/src/bin/pistond.js b/api/src/bin/pistond.js index 1712c36..1478c0c 100755 --- a/api/src/bin/pistond.js +++ b/api/src/bin/pistond.js @@ -43,7 +43,22 @@ expressWs(app); `nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames` ) .toString(); - const runtime_names = JSON.parse(runtimes_data); + const runtime_names_unordered = JSON.parse(runtimes_data); + + const priorities_data = cp + .execSync( + `nix eval --json ${config.flake_path}#pistonRuntimePriorities` + ) + .toString(); + const priorities = JSON.parse(priorities_data).filter(runtime => + runtime_names_unordered.includes(runtime) + ); + const runtime_names = [ + ...priorities, + ...runtime_names_unordered.filter( + runtime => !priorities.includes(runtime) + ), + ]; logger.info('Loading the runtimes from the flakes'); const runtimes = runtime_names.map(runtime_name => { diff --git a/flake.nix b/flake.nix index d53fc00..1e7d940 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,7 @@ "bash-only" = runtimeList ["bash"]; "none" = { }; }; + pistonRuntimePriorities = import ./runtimes/priorities; legacyPackages."${system}" = rec { nosocket = (import ./nosocket { inherit pkgs; }).package; diff --git a/runtimes/priorities/default.nix b/runtimes/priorities/default.nix index 128310a..38bd89e 100644 --- a/runtimes/priorities/default.nix +++ b/runtimes/priorities/default.nix @@ -1,7 +1,7 @@ [ "node-javascript" - "python2" "python3" + "python2" "bash" "clojure" "cobol-gnu-cobol" From 3149cd80fad6fb67e40f9adf91ef23f3a1042cec Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 5 Jun 2022 11:31:49 +0200 Subject: [PATCH 4/7] Add the priorities directly in flake.nix --- flake.nix | 7 +++- runtimes/priorities/default.nix | 66 --------------------------------- runtimes/scaffold.sh | 8 +--- 3 files changed, 8 insertions(+), 73 deletions(-) delete mode 100644 runtimes/priorities/default.nix diff --git a/flake.nix b/flake.nix index 1e7d940..9136cbe 100644 --- a/flake.nix +++ b/flake.nix @@ -65,7 +65,12 @@ "bash-only" = runtimeList ["bash"]; "none" = { }; }; - pistonRuntimePriorities = import ./runtimes/priorities; + pistonRuntimePriorities = [ + "mono-csharp" + "dotnet-sdk-csharp" + "python3" + "python2" + ]; legacyPackages."${system}" = rec { nosocket = (import ./nosocket { inherit pkgs; }).package; diff --git a/runtimes/priorities/default.nix b/runtimes/priorities/default.nix deleted file mode 100644 index 38bd89e..0000000 --- a/runtimes/priorities/default.nix +++ /dev/null @@ -1,66 +0,0 @@ -[ - "node-javascript" - "python3" - "python2" - "bash" - "clojure" - "cobol-gnu-cobol" - "crystal" - "dart" - "dash" - "deno-javascript" - "deno-typescript" - "elixir" - "erlang" - "gawk-awk" - "openjdk11_headless-java" - "ruby" - "zig" - "vlang" - "swift" - "node-typescript" - "sqlite" - "rscript" - "raku" - "racket" - "powershell" - "prolog" - "ponylang" - "php" - "perl" - "octave" - "ocaml" - "nim" - "nasm" - "nasm-nasm64" - "mono-csharp" - "lua" - "lolcode" - "sbcl-lisp" - "jvm-kotlin" - "julia" - "jelly" - "openjdk-java" - "iverilog" - "ghc-haskell" - "groovy" - "go" - "gcc-c" - "gcc-c++" - "gcc-d" - "gcc-fortran" - "yabasic" - "emacs" - "gnat-ada" - "rust" - "dotnet-sdk-csharp" - "dotnet-sdk-fsharp" - "dotnet-sdk-fsharp-interactive" - "dotnet-sdk-visual-basic" - "fpc-pascal" - "brainfuck" - "node-coffeescript" - "jvm-scala" - "llvm_ir" - "mono-basic" -] diff --git a/runtimes/scaffold.sh b/runtimes/scaffold.sh index 11bf5a6..2a49ef2 100755 --- a/runtimes/scaffold.sh +++ b/runtimes/scaffold.sh @@ -32,13 +32,9 @@ else .scaffold.nix > $NAME.nix echo "}" >> default.nix - sed -i '$d' ./priorities/default.nix - echo " \"$NAME\"" >> ./priorities/default.nix - echo "]" >> ./priorities/default.nix - - git add $NAME.nix default.nix ./priorities + git add $NAME.nix default.nix echo "Scaffolded $NAME" echo "Edit $NAME.nix to get started" echo "Once you are done, run ./piston test $NAME to test it" -fi +fi \ No newline at end of file From 43389b7d5f8c2bf91f54be6b33884c65544e02c8 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 5 Jun 2022 11:39:34 +0200 Subject: [PATCH 5/7] Add python aliases --- runtimes/python2.nix | 4 +++- runtimes/python3.nix | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/runtimes/python2.nix b/runtimes/python2.nix index 9b89a20..4a8b306 100644 --- a/runtimes/python2.nix +++ b/runtimes/python2.nix @@ -7,6 +7,8 @@ in piston.mkRuntime { aliases = [ "py2" + "python" + "py" ]; run = '' @@ -22,4 +24,4 @@ in piston.mkRuntime { }; }) ]; -} \ No newline at end of file +} diff --git a/runtimes/python3.nix b/runtimes/python3.nix index 9dc2682..3831bca 100644 --- a/runtimes/python3.nix +++ b/runtimes/python3.nix @@ -8,6 +8,7 @@ in piston.mkRuntime { aliases = [ "py3" "py" + "python" ]; run = '' @@ -23,4 +24,4 @@ in piston.mkRuntime { }; }) ]; -} \ No newline at end of file +} From 26203f60499068d5d966a79b14783e4e423a1c4f Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 5 Jun 2022 11:50:29 +0200 Subject: [PATCH 6/7] Add more runtime priorities --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index 9136cbe..8fd37d9 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,12 @@ "dotnet-sdk-csharp" "python3" "python2" + "node-javascript" + "node-typescript" + "deno-javascript" + "deno-typescript" + "mono-basic" + "dotnet-sdk-visual-basic" ]; legacyPackages."${system}" = rec { From a664cd4d494195d8303c154e5b590b085f0aecba Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 5 Jun 2022 12:24:56 +0200 Subject: [PATCH 7/7] Rename runtime priorities to mainstream runtimes --- api/src/bin/pistond.js | 10 +++++----- flake.nix | 7 +------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/api/src/bin/pistond.js b/api/src/bin/pistond.js index 1478c0c..c07e08d 100755 --- a/api/src/bin/pistond.js +++ b/api/src/bin/pistond.js @@ -45,18 +45,18 @@ expressWs(app); .toString(); const runtime_names_unordered = JSON.parse(runtimes_data); - const priorities_data = cp + const mainstream_runtimes_data = cp .execSync( - `nix eval --json ${config.flake_path}#pistonRuntimePriorities` + `nix eval --json ${config.flake_path}#pistonMainstreamRuntimes` ) .toString(); - const priorities = JSON.parse(priorities_data).filter(runtime => + const mainstream_runtimes = JSON.parse(mainstream_runtimes_data).filter(runtime => runtime_names_unordered.includes(runtime) ); const runtime_names = [ - ...priorities, + ...mainstream_runtimes, ...runtime_names_unordered.filter( - runtime => !priorities.includes(runtime) + runtime => !mainstream_runtimes.includes(runtime) ), ]; diff --git a/flake.nix b/flake.nix index 8fd37d9..2b9c50d 100644 --- a/flake.nix +++ b/flake.nix @@ -65,17 +65,12 @@ "bash-only" = runtimeList ["bash"]; "none" = { }; }; - pistonRuntimePriorities = [ + pistonMainstreamRuntimes = [ "mono-csharp" - "dotnet-sdk-csharp" "python3" - "python2" "node-javascript" "node-typescript" - "deno-javascript" - "deno-typescript" "mono-basic" - "dotnet-sdk-visual-basic" ]; legacyPackages."${system}" = rec {