From f94ba284df1da6d802a57db75e00b621a486bdb2 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Sun, 6 Feb 2022 21:41:18 -0700 Subject: [PATCH] ocaml for nix --- packages/ocaml/4.12.0/build.sh | 17 -------------- packages/ocaml/4.12.0/compile | 5 ----- packages/ocaml/4.12.0/environment | 3 --- packages/ocaml/4.12.0/metadata.json | 5 ----- packages/ocaml/4.12.0/run | 4 ---- packages/ocaml/4.12.0/test.ml | 1 - runtimes/default.nix | 1 + runtimes/ocaml.nix | 35 +++++++++++++++++++++++++++++ 8 files changed, 36 insertions(+), 35 deletions(-) delete mode 100755 packages/ocaml/4.12.0/build.sh delete mode 100644 packages/ocaml/4.12.0/compile delete mode 100644 packages/ocaml/4.12.0/environment delete mode 100644 packages/ocaml/4.12.0/metadata.json delete mode 100644 packages/ocaml/4.12.0/run delete mode 100644 packages/ocaml/4.12.0/test.ml create mode 100644 runtimes/ocaml.nix diff --git a/packages/ocaml/4.12.0/build.sh b/packages/ocaml/4.12.0/build.sh deleted file mode 100755 index fd91cdd..0000000 --- a/packages/ocaml/4.12.0/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PREFIX=$(realpath $(dirname $0)) - -mkdir -p build -cd build - -curl -L "https://github.com/ocaml/ocaml/archive/4.12.0.tar.gz" -o ocaml.tar.gz -tar xzf ocaml.tar.gz --strip-components=1 -rm ocaml.tar.gz - -./configure --prefix="$PREFIX" -make -j$(nproc) -make install -j$(nproc) - -cd .. -rm -rf build diff --git a/packages/ocaml/4.12.0/compile b/packages/ocaml/4.12.0/compile deleted file mode 100644 index 39ddd0b..0000000 --- a/packages/ocaml/4.12.0/compile +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -rename 's/$/\.ml/' "$@" # Add .ml extension - -ocamlc -o out *.ml diff --git a/packages/ocaml/4.12.0/environment b/packages/ocaml/4.12.0/environment deleted file mode 100644 index 116e7aa..0000000 --- a/packages/ocaml/4.12.0/environment +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -export PATH=$PWD/bin:$PATH diff --git a/packages/ocaml/4.12.0/metadata.json b/packages/ocaml/4.12.0/metadata.json deleted file mode 100644 index 6c2f733..0000000 --- a/packages/ocaml/4.12.0/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "ocaml", - "version": "4.12.0", - "aliases": ["ocaml", "ml"] -} diff --git a/packages/ocaml/4.12.0/run b/packages/ocaml/4.12.0/run deleted file mode 100644 index e2663b1..0000000 --- a/packages/ocaml/4.12.0/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -shift -./out "$@" diff --git a/packages/ocaml/4.12.0/test.ml b/packages/ocaml/4.12.0/test.ml deleted file mode 100644 index ef98f8c..0000000 --- a/packages/ocaml/4.12.0/test.ml +++ /dev/null @@ -1 +0,0 @@ -print_string "OK\n"; diff --git a/runtimes/default.nix b/runtimes/default.nix index 3a80376..8da8f44 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -29,4 +29,5 @@ args: { "php" = import ./php.nix args; "perl" = import ./perl.nix args; "octave" = import ./octave.nix args; + "ocaml" = import ./ocaml.nix args; } diff --git a/runtimes/ocaml.nix b/runtimes/ocaml.nix new file mode 100644 index 0000000..18fa1bb --- /dev/null +++ b/runtimes/ocaml.nix @@ -0,0 +1,35 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.ocaml; +in piston.mkRuntime { + language = "ocaml"; + version = pkg.version; + + aliases = [ + "ml" + ]; + + compile = '' + rename 's/$/\.ml/' "$@" # Add .ml extension + ${pkg}/bin/ocamlc -o out *.ml + ''; + + run = '' + shift + ./out "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.ml" = '' + print_string "OK\n"; + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.ml"; + }) + ]; +} \ No newline at end of file