From d688ec3fe3177e8ae7da91173d1a90223cc68b41 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Mon, 7 Feb 2022 11:04:40 -0700 Subject: [PATCH] add mono csharp --- runtimes/default.nix | 1 + runtimes/mono-csharp.nix | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 runtimes/mono-csharp.nix diff --git a/runtimes/default.nix b/runtimes/default.nix index f7b30c3..d25201b 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -33,4 +33,5 @@ args: { "nim" = import ./nim.nix args; "nasm" = import ./nasm.nix args; "nasm-nasm64" = import ./nasm-nasm64.nix args; + "mono-csharp" = import ./mono-csharp.nix args; } diff --git a/runtimes/mono-csharp.nix b/runtimes/mono-csharp.nix new file mode 100644 index 0000000..7be9078 --- /dev/null +++ b/runtimes/mono-csharp.nix @@ -0,0 +1,49 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.mono; +in piston.mkRuntime { + language = "csharp"; + version = pkg.version; + runtime = "mono"; + + aliases = [ + "mono" + "mono-csharp" + "mono-c#" + "mono-cs" + "c#" + "cs" + ]; + + compile = '' + rename 's/$/\.cs/' "$@" # Add .cs extension + ${pkg}/bin/csc -out:out *.cs + ''; + + run = '' + shift + ${pkg}/bin/mono out "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.cs" = '' + using System; + + public class Test + { + public static void Main(string[] args) + { + Console.WriteLine("OK"); + } + } + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.cs"; + }) + ]; +} \ No newline at end of file