ocaml template

This commit is contained in:
Rachel Lambda Samuelsson 2024-04-08 21:04:23 +02:00
parent a745c16de8
commit 8be71c6d1c
10 changed files with 129 additions and 0 deletions

1
ocaml/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

4
ocaml/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.direnv
my_project.opam
_build/
result

4
ocaml/bin/dune Normal file
View File

@ -0,0 +1,4 @@
(executable
(public_name my_project)
(name main)
(libraries my_project base64))

2
ocaml/bin/main.ml Normal file
View File

@ -0,0 +1,2 @@
let () = let open Base64 in
print_endline (decode_exn "bWphdSEh")

26
ocaml/dune-project Normal file
View File

@ -0,0 +1,26 @@
(lang dune 3.11)
(name my_project)
(generate_opam_files true)
(source
(github username/reponame))
(authors "Author Name")
(maintainers "Maintainer Name")
(license LICENSE)
(documentation https://url/to/documentation)
(package
(name my_project)
(synopsis "A short synopsis")
(description "A longer description")
(depends ocaml dune base64)
(tags
(topics "to describe" your project)))
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project

58
ocaml/flake.lock Normal file
View File

@ -0,0 +1,58 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1707091808,
"narHash": "sha256-LahKBAfGbY836gtpVNnWwBTIzN7yf/uYM/S0g393r0Y=",
"path": "/nix/store/ws5098bfhd2kzvg3yxwb2ggvl05h7gfd-source",
"rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

30
ocaml/flake.nix Normal file
View File

@ -0,0 +1,30 @@
{
description = "A bare minimum OCaml flake";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (sys:
let pkgs = import nixpkgs { system = sys; };
opkgs = pkgs.ocamlPackages; # pkgs.ocaml-ng.ocamlPackages_VERSION
project = opkgs.buildDunePackage {
pname = "my_project";
version = "0.1.0";
src = ./.;
buildInputs = with opkgs; [
base64
];
};
in {
packages.default = project;
devShells.default = pkgs.mkShell {
packages = [ opkgs.utop ];
inputsFrom = [ project ];
};
}
);
}

2
ocaml/lib/dune Normal file
View File

@ -0,0 +1,2 @@
(library
(name my_project))

2
ocaml/test/dune Normal file
View File

@ -0,0 +1,2 @@
(test
(name my_project))

0
ocaml/test/my_project.ml Normal file
View File