From 5ee28d918a8945224563bdfed293a0ff4b6e5757 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Mon, 31 Jan 2022 19:35:06 -0700 Subject: [PATCH] add ruby 3.1.0 --- runtimes/default.nix | 1 + runtimes/ruby.nix | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 runtimes/ruby.nix diff --git a/runtimes/default.nix b/runtimes/default.nix index bfc0e2a..dbf454c 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -14,4 +14,5 @@ args: { "erlang" = import ./erlang.nix args; "gawk-awk" = import ./gawk-awk.nix args; "openjdk11_headless-java" = import ./openjdk11_headless-java.nix args; + "ruby" = import ./ruby.nix args; } diff --git a/runtimes/ruby.nix b/runtimes/ruby.nix new file mode 100644 index 0000000..6673222 --- /dev/null +++ b/runtimes/ruby.nix @@ -0,0 +1,57 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.ruby_3_1; # ruby 3.1 stable from unstable channel +in piston.mkRuntime { + language = "ruby"; + version = pkg.version; + + aliases = [ + "ruby3" + "rb" + ]; + + run = '' + ${pkg}/bin/ruby "$@" + ''; + + # Run the following command to test the package: + # $ ./piston test ruby + tests = [ + # standard output test + (piston.mkTest { + files = { + "test.rb" = '' + puts("OK"); + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.rb"; + }) + # args test + (piston.mkTest { + files = { + "test.rb" = '' + puts $*; + ''; + }; + args = ["OK"]; + stdin = ""; + packages = []; + main = "test.rb"; + }) + # stdin test + (piston.mkTest { + files = { + "test.rb" = '' + print Kernel.gets; + ''; + }; + args = []; + stdin = "OK"; + packages = []; + main = "test.rb"; + }) + ]; +} \ No newline at end of file