From f7fc2cff1febbd5b265d35230a00750170fd691b Mon Sep 17 00:00:00 2001 From: Vincent Lafeychine Date: Fri, 19 Jan 2024 23:08:08 +0100 Subject: [PATCH] feat(nix): package + devShell --- dune-project | 10 +++++-- flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 54 ++++++++++++++++++++++++++++++++++++ lib/dune | 2 +- src/dune | 14 ++-------- 5 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/dune-project b/dune-project index ae5efa9..6e9c4c8 100644 --- a/dune-project +++ b/dune-project @@ -1,2 +1,8 @@ -(lang dune 2.0) -(using menhir 2.0) +(lang dune 3.4) +(using menhir 2.1) +(name cerise-interpreter) + +; https://dune.readthedocs.io/en/stable/concepts.html#package-specification +(package + (name cerise-interpreter) + (synopsis "Interpreter for Cerise capability machine")) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..33d7400 --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1694857738, + "narHash": "sha256-bxxNyLHjhu0N8T3REINXQ2ZkJco0ABFPn6PIe2QUfqo=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "41fd48e00c22b4ced525af521ead8792402de0ea", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697915759, + "narHash": "sha256-WyMj5jGcecD+KC8gEs+wFth1J1wjisZf8kVZH13f1Zo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "51d906d2341c9e866e48c2efcaac0f2d70bfd43e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "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..b4f45dd --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix-filter.url = "github:numtide/nix-filter"; + }; + + outputs = { self, flake-utils, nixpkgs, nix-filter}: + flake-utils.lib.eachSystem ["x86_64-linux"] (system: + let + pkgs = import nixpkgs { inherit system; }; + ocamlPackages = pkgs.ocamlPackages; + in with ocamlPackages; rec { + defaultPackage = buildDunePackage { + pname = "cerise-interpreter"; + version = "0.0.0"; + duneVersion = "3"; + + src = with nix-filter.lib; + nix-filter { + root = ./.; + include = [ + "dune-project" + (inDirectory "src") + (inDirectory "lib") + (inDirectory "tests") + ]; + }; + + nativeBuildInputs = [menhir]; + buildInputs = [containers notty zarith]; + checkInputs = [alcotest]; + + doCheck = true; + + meta = with pkgs.lib; { + description = "Cerise interpreter, interpreter for capability machines"; + homepage = "https://github.com/logsem/cerise-interpreter"; + license = licenses.bsd3; + }; + }; + + devShell = + pkgs.mkShell { + packages = [ + ocaml-lsp + merlin + ocamlformat + ]; + + inputsFrom = [defaultPackage]; + }; + }); +} diff --git a/lib/dune b/lib/dune index 1a13590..5baaefc 100644 --- a/lib/dune +++ b/lib/dune @@ -1,6 +1,6 @@ (library (name libinterp) - (libraries zarith notty notty.unix containers)) + (libraries containers notty notty.unix zarith)) (ocamllex lexer lexer_regfile) (menhir (modules parser parser_regfile) ) diff --git a/src/dune b/src/dune index fab50be..953e6c7 100644 --- a/src/dune +++ b/src/dune @@ -1,14 +1,6 @@ (executable (name interpreter) + (public_name cerise-interpreter) (modules interpreter) - (libraries libinterp notty notty.unix containers)) - -(executable - (name awkward_ucaps) - (modules awkward_ucaps) - (libraries libinterp)) - -(executable - (name awkward_dcaps) - (modules awkward_dcaps) - (libraries libinterp)) + ; (libraries containers libinterp notty notty.unix)) + (libraries containers libinterp notty))