ocaml for nix

This commit is contained in:
Dan Vargas 2022-02-06 21:41:18 -07:00
parent e7c5b557f9
commit f94ba284df
8 changed files with 36 additions and 35 deletions

View File

@ -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

View File

@ -1,5 +0,0 @@
#!/bin/bash
rename 's/$/\.ml/' "$@" # Add .ml extension
ocamlc -o out *.ml

View File

@ -1,3 +0,0 @@
#!/bin/bash
export PATH=$PWD/bin:$PATH

View File

@ -1,5 +0,0 @@
{
"language": "ocaml",
"version": "4.12.0",
"aliases": ["ocaml", "ml"]
}

View File

@ -1,4 +0,0 @@
#!/bin/bash
shift
./out "$@"

View File

@ -1 +0,0 @@
print_string "OK\n";

View File

@ -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;
}

35
runtimes/ocaml.nix Normal file
View File

@ -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";
})
];
}