aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/dune4
-rw-r--r--bin/main.ml1
-rw-r--r--dune-project26
-rw-r--r--flake.lock73
-rw-r--r--flake.nix217
-rw-r--r--lib/dune2
-rw-r--r--relational_engine.opam31
-rw-r--r--test/dune2
-rw-r--r--test/test_relational_engine.ml0
9 files changed, 356 insertions, 0 deletions
diff --git a/bin/dune b/bin/dune
new file mode 100644
index 0000000..0888311
--- /dev/null
+++ b/bin/dune
@@ -0,0 +1,4 @@
+(executable
+ (public_name relational_engine)
+ (name main)
+ (libraries relational_engine))
diff --git a/bin/main.ml b/bin/main.ml
new file mode 100644
index 0000000..7bf6048
--- /dev/null
+++ b/bin/main.ml
@@ -0,0 +1 @@
+let () = print_endline "Hello, World!"
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000..14a604b
--- /dev/null
+++ b/dune-project
@@ -0,0 +1,26 @@
+(lang dune 3.16)
+
+(name relational_engine)
+
+(generate_opam_files true)
+
+(source
+ (github username/reponame))
+
+(authors "Author Name")
+
+(maintainers "Maintainer Name")
+
+(license LICENSE)
+
+(documentation https://url/to/documentation)
+
+(package
+ (name relational_engine)
+ (synopsis "A short synopsis")
+ (description "A longer description")
+ (depends ocaml dune)
+ (tags
+ (topics "to describe" your project)))
+
+; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..735ecfb
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,73 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1726560853,
+ "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nix-filter": {
+ "locked": {
+ "lastModified": 1710156097,
+ "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=",
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "rev": "3342559a24e85fc164b295c3444e8a139924675b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 0,
+ "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
+ "path": "/nix/store/5w3dp0m37794iffsbm9vd9f1xmmhda6i-source",
+ "type": "path"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nix-filter": "nix-filter",
+ "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/flake.nix b/flake.nix
new file mode 100644
index 0000000..2d50b55
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,217 @@
+{
+ description = "A compiler for a statically-typed relational programming language";
+
+ # Flake dependency specification
+ #
+ # To update all flake inputs:
+ #
+ # $ nix flake update --commit-lockfile
+ #
+ # To update individual flake inputs:
+ #
+ # $ nix flake lock --update-input <input> ... --commit-lockfile
+ #
+ inputs = {
+ # Convenience functions for writing flakes
+ flake-utils.url = "github:numtide/flake-utils";
+ # Precisely filter files copied to the nix store
+ nix-filter.url = "github:numtide/nix-filter";
+ };
+
+ outputs = { self, nixpkgs, flake-utils, nix-filter }:
+ # Construct an output set that supports a number of default systems
+ flake-utils.lib.eachDefaultSystem (system:
+ let
+ # Legacy packages that have not been converted to flakes
+ legacyPackages = nixpkgs.legacyPackages.${system};
+ # OCaml packages available on nixpkgs
+ ocamlPackages = legacyPackages.ocamlPackages;
+ # Library functions from nixpkgs
+ lib = legacyPackages.lib;
+
+ # Filtered sources (prevents unecessary rebuilds)
+ sources = {
+ ocaml = nix-filter.lib {
+ root = ./.;
+ include = [
+ ".ocamlformat"
+ "dune-project"
+ (nix-filter.lib.inDirectory "bin")
+ (nix-filter.lib.inDirectory "lib")
+ (nix-filter.lib.inDirectory "test")
+ ];
+ };
+
+ nix = nix-filter.lib {
+ root = ./.;
+ include = [
+ (nix-filter.lib.matchExt "nix")
+ ];
+ };
+ };
+ in
+ {
+ # Exposed packages that can be built or run with `nix build` or
+ # `nix run` respectively:
+ #
+ # $ nix build .#<name>
+ # $ nix run .#<name> -- <args?>
+ #
+ packages = {
+ # The package that will be built or run by default. For example:
+ #
+ # $ nix build
+ # $ nix run -- <args?>
+ #
+ default = self.packages.${system}.relational_engine;
+
+ relational_engine = ocamlPackages.buildDunePackage {
+ pname = "relational_engine";
+ version = "0.1.0";
+ duneVersion = "3";
+ src = sources.ocaml;
+
+ buildInputs = [
+ # Ocaml package dependencies needed to build go here.
+ ];
+
+ strictDeps = true;
+
+ preBuild = ''
+ dune build relational_engine.opam
+ '';
+ };
+ };
+
+ # Flake checks
+ #
+ # $ nix flake check
+ #
+ checks = {
+ # Run tests for the `relational_engine` package
+ relational_engine =
+ let
+ # Patches calls to dune commands to produce log-friendly output
+ # when using `nix ... --print-build-log`. Ideally there would be
+ # support for one or more of the following:
+ #
+ # In Dune:
+ #
+ # - have workspace-specific dune configuration files
+ #
+ # In NixPkgs:
+ #
+ # - allow dune flags to be set in in `ocamlPackages.buildDunePackage`
+ # - alter `ocamlPackages.buildDunePackage` to use `--display=short`
+ # - alter `ocamlPackages.buildDunePackage` to allow `--config-file=FILE` to be set
+ patchDuneCommand =
+ let
+ subcmds = [ "build" "test" "runtest" "install" ];
+ in
+ lib.replaceStrings
+ (lib.lists.map (subcmd: "dune ${subcmd}") subcmds)
+ (lib.lists.map (subcmd: "dune ${subcmd} --display=short") subcmds);
+ in
+
+ self.packages.${system}.relational_engine.overrideAttrs
+ (oldAttrs: {
+ name = "check-${oldAttrs.name}";
+ doCheck = true;
+ buildPhase = patchDuneCommand oldAttrs.buildPhase;
+ checkPhase = patchDuneCommand oldAttrs.checkPhase;
+ # skip installation (this will be tested in the `relational_engine-app` check)
+ installPhase = "touch $out";
+ });
+
+ # Check Dune and OCaml formatting
+ dune-fmt = legacyPackages.runCommand "check-dune-fmt"
+ {
+ nativeBuildInputs = [
+ ocamlPackages.dune_3
+ ocamlPackages.ocaml
+ legacyPackages.ocamlformat
+ ];
+ }
+ ''
+ echo "checking dune and ocaml formatting"
+ dune build \
+ --display=short \
+ --no-print-directory \
+ --root="${sources.ocaml}" \
+ --build-dir="$(pwd)/_build" \
+ @fmt
+ touch $out
+ '';
+
+ # Check documentation generation
+ dune-doc = legacyPackages.runCommand "check-dune-doc"
+ {
+ ODOC_WARN_ERROR = "true";
+ nativeBuildInputs = [
+ ocamlPackages.dune_3
+ ocamlPackages.ocaml
+ ocamlPackages.odoc
+ ];
+ }
+ ''
+ echo "checking ocaml documentation"
+ dune build \
+ --display=short \
+ --no-print-directory \
+ --root="${sources.ocaml}" \
+ --build-dir="$(pwd)/_build" \
+ @doc
+ touch $out
+ '';
+
+ # Check Nix formatting
+ nixpkgs-fmt = legacyPackages.runCommand "check-nixpkgs-fmt"
+ { nativeBuildInputs = [ legacyPackages.nixpkgs-fmt ]; }
+ ''
+ echo "checking nix formatting"
+ nixpkgs-fmt --check ${sources.nix}
+ touch $out
+ '';
+ };
+
+ # Development shells
+ #
+ # $ nix develop .#<name>
+ # $ nix develop .#<name> --command dune build @test
+ #
+ # [Direnv](https://direnv.net/) is recommended for automatically loading
+ # development environments in your shell. For example:
+ #
+ # $ echo "use flake" > .envrc && direnv allow
+ # $ dune build @test
+ #
+ devShells = {
+ default = legacyPackages.mkShell {
+ # Development tools
+ packages = [
+ # Source file formatting
+ legacyPackages.nixpkgs-fmt
+ legacyPackages.ocamlformat
+ # For `dune build --watch ...`
+ legacyPackages.fswatch
+ # For `dune build @doc`
+ ocamlPackages.odoc
+ # OCaml editor support
+ ocamlPackages.ocaml-lsp
+ # Nicely formatted types on hover
+ ocamlPackages.ocamlformat-rpc-lib
+ # Fancy REPL thing
+ ocamlPackages.utop
+ # Libraries
+ ocamlPackages.menhir
+ ocamlPackages.batteries
+ ];
+
+ # Tools from packages
+ inputsFrom = [
+ self.packages.${system}.relational_engine
+ ];
+ };
+ };
+ });
+}
diff --git a/lib/dune b/lib/dune
new file mode 100644
index 0000000..5d95cc5
--- /dev/null
+++ b/lib/dune
@@ -0,0 +1,2 @@
+(library
+ (name relational_engine))
diff --git a/relational_engine.opam b/relational_engine.opam
new file mode 100644
index 0000000..b296c11
--- /dev/null
+++ b/relational_engine.opam
@@ -0,0 +1,31 @@
+# This file is generated by dune, edit dune-project instead
+opam-version: "2.0"
+synopsis: "A short synopsis"
+description: "A longer description"
+maintainer: ["Maintainer Name"]
+authors: ["Author Name"]
+license: "LICENSE"
+tags: ["topics" "to describe" "your" "project"]
+homepage: "https://github.com/username/reponame"
+doc: "https://url/to/documentation"
+bug-reports: "https://github.com/username/reponame/issues"
+depends: [
+ "ocaml"
+ "dune" {>= "3.16"}
+ "odoc" {with-doc}
+]
+build: [
+ ["dune" "subst"] {dev}
+ [
+ "dune"
+ "build"
+ "-p"
+ name
+ "-j"
+ jobs
+ "@install"
+ "@runtest" {with-test}
+ "@doc" {with-doc}
+ ]
+]
+dev-repo: "git+https://github.com/username/reponame.git"
diff --git a/test/dune b/test/dune
new file mode 100644
index 0000000..8f2e6a4
--- /dev/null
+++ b/test/dune
@@ -0,0 +1,2 @@
+(test
+ (name test_relational_engine))
diff --git a/test/test_relational_engine.ml b/test/test_relational_engine.ml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/test_relational_engine.ml