From c4ceaa696412ca8724e7e143c9fcb7dbc2eb05b9 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Thu, 24 Feb 2022 17:46:20 +0200 Subject: [PATCH] Add fsharp-interactive --- runtimes/default.nix | 1 + runtimes/dotnet-sdk-fsharp-interactive.nix | 52 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 runtimes/dotnet-sdk-fsharp-interactive.nix diff --git a/runtimes/default.nix b/runtimes/default.nix index 9dab5f6..27466cb 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -55,4 +55,5 @@ args: { "rust" = import ./rust.nix args; "dotnet-sdk-csharp" = import ./dotnet-sdk-csharp.nix args; "dotnet-sdk-fsharp" = import ./dotnet-sdk-fsharp.nix args; + "dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args; } diff --git a/runtimes/dotnet-sdk-fsharp-interactive.nix b/runtimes/dotnet-sdk-fsharp-interactive.nix new file mode 100644 index 0000000..9e77db1 --- /dev/null +++ b/runtimes/dotnet-sdk-fsharp-interactive.nix @@ -0,0 +1,52 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.dotnet-sdk; +in piston.mkRuntime { + language = "fsharp-interactive"; + version = pkg.version; + runtime = "dotnet-sdk"; + + aliases = [ + "fsi" + "fsx" + "fsi.net" + "fsi-dotnet" + "dotnet-fsi" + "fsharp-interactive.net" + "fsharp-interactive-dotnet" + "dotnet-fsharp-interactive" + "f#-interactive" + "f#-interactive.net" + "f#-interactive-dotnet" + "dotnet-f#-interactive" + "fs-interactive" + "fs-interactive.net" + "fs-interactive-dotnet" + "dotnet-fs-interactive" + ]; + + run = '' + export HOME=$PWD + FILENAME=$1 + rename 's/$/\.fsx/' $FILENAME # Add .fsx extension + shift + ${pkg}/dotnet fsi --help > /dev/null + ${pkg}/dotnet fsi $FILENAME.fsx "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.fsx" = '' + open System + let args : string array = fsi.CommandLineArgs |> Array.tail + Console.WriteLine args[0] + ''; + }; + args = ["OK"]; + stdin = ""; + packages = []; + main = "test.fsx"; + }) + ]; +}