From 8be71c6d1c3e4e07cde42ce8606f7ad78478c44b Mon Sep 17 00:00:00 2001 From: depsterr Date: Mon, 8 Apr 2024 21:04:23 +0200 Subject: [PATCH] ocaml template --- ocaml/.envrc | 1 + ocaml/.gitignore | 4 +++ ocaml/bin/dune | 4 +++ ocaml/bin/main.ml | 2 ++ ocaml/dune-project | 26 ++++++++++++++++++ ocaml/flake.lock | 58 ++++++++++++++++++++++++++++++++++++++++ ocaml/flake.nix | 30 +++++++++++++++++++++ ocaml/lib/dune | 2 ++ ocaml/test/dune | 2 ++ ocaml/test/my_project.ml | 0 10 files changed, 129 insertions(+) create mode 100644 ocaml/.envrc create mode 100644 ocaml/.gitignore create mode 100644 ocaml/bin/dune create mode 100644 ocaml/bin/main.ml create mode 100644 ocaml/dune-project create mode 100644 ocaml/flake.lock create mode 100644 ocaml/flake.nix create mode 100644 ocaml/lib/dune create mode 100644 ocaml/test/dune create mode 100644 ocaml/test/my_project.ml diff --git a/ocaml/.envrc b/ocaml/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/ocaml/.envrc @@ -0,0 +1 @@ +use flake diff --git a/ocaml/.gitignore b/ocaml/.gitignore new file mode 100644 index 0000000..d72f3bb --- /dev/null +++ b/ocaml/.gitignore @@ -0,0 +1,4 @@ +.direnv +my_project.opam +_build/ +result diff --git a/ocaml/bin/dune b/ocaml/bin/dune new file mode 100644 index 0000000..89a6b12 --- /dev/null +++ b/ocaml/bin/dune @@ -0,0 +1,4 @@ +(executable + (public_name my_project) + (name main) + (libraries my_project base64)) diff --git a/ocaml/bin/main.ml b/ocaml/bin/main.ml new file mode 100644 index 0000000..bc6119b --- /dev/null +++ b/ocaml/bin/main.ml @@ -0,0 +1,2 @@ +let () = let open Base64 in + print_endline (decode_exn "bWphdSEh") diff --git a/ocaml/dune-project b/ocaml/dune-project new file mode 100644 index 0000000..81b5bf8 --- /dev/null +++ b/ocaml/dune-project @@ -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 diff --git a/ocaml/flake.lock b/ocaml/flake.lock new file mode 100644 index 0000000..8ba0907 --- /dev/null +++ b/ocaml/flake.lock @@ -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 +} diff --git a/ocaml/flake.nix b/ocaml/flake.nix new file mode 100644 index 0000000..5c2bb62 --- /dev/null +++ b/ocaml/flake.nix @@ -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 ]; + }; + } + ); +} diff --git a/ocaml/lib/dune b/ocaml/lib/dune new file mode 100644 index 0000000..5804345 --- /dev/null +++ b/ocaml/lib/dune @@ -0,0 +1,2 @@ +(library + (name my_project)) diff --git a/ocaml/test/dune b/ocaml/test/dune new file mode 100644 index 0000000..954c50f --- /dev/null +++ b/ocaml/test/dune @@ -0,0 +1,2 @@ +(test + (name my_project)) diff --git a/ocaml/test/my_project.ml b/ocaml/test/my_project.ml new file mode 100644 index 0000000..e69de29