From cf0fffed43d0ca7618cd0013411151e057b7a32a Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Mon, 18 May 2026 12:35:26 -0300 Subject: RNT interface Co-authored-by: Estevan Castilho --- flake.nix | 106 +++++++++++--------------------------------------------------- 1 file changed, 19 insertions(+), 87 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 127102c..67b905c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,22 @@ { description = "Sakura Relational Engine"; - - # Flake dependency specification - # - # To update all flake inputs: - # - # $ nix flake update --commit-lockfile - # - # To update individual flake inputs: - # - # $ nix flake lock --update-input ... --commit-lockfile - # inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - # 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"; + RNT = { + type = "github"; + owner = "mmagueta"; + repo = "RNT"; + ref = "branching"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils, nix-filter }: - # Construct an output set that supports a number of default systems + outputs = { self, nixpkgs, flake-utils, nix-filter, RNT }: flake-utils.lib.eachDefaultSystem (system: let - # Legacy packages that have not been converted to flakes legacyPackages = nixpkgs.legacyPackages.${system}; - # OCaml packages available on nixpkgs - # Library functions from nixpkgs lib = legacyPackages.lib; ocamlPackages = legacyPackages.ocamlPackages; ppx_protocol_conv = @@ -40,7 +30,7 @@ ppx_protocol_conv = ppx_protocol_conv; fetchFromGitHub = legacyPackages.fetchFromGitHub; ocamlPackages = ocamlPackages; }; - # Filtered sources (prevents unecessary rebuilds) + rnt = RNT.packages.${system}.default; sources = { ocaml = nix-filter.lib { root = ./.; @@ -61,18 +51,7 @@ }; }; in { - # Exposed packages that can be built or run with `nix build` or - # `nix run` respectively: - # - # $ nix build .# - # $ nix run .# -- - # packages = { - # The package that will be built or run by default. For example: - # - # $ nix build - # $ nix run -- - # default = self.packages.${system}.relational_engine; relational_engine = ocamlPackages.buildDunePackage { @@ -82,7 +61,8 @@ src = sources.ocaml; buildInputs = [ ppx_protocol_conv_xml_light - ppx_protocol_conv ] + ppx_protocol_conv + rnt ] ++ (with ocamlPackages; [ sha ctypes @@ -101,26 +81,8 @@ }; }; - # 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 @@ -134,11 +96,9 @@ 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 @@ -168,6 +128,7 @@ ocamlPackages.lwt-exit ocamlPackages.ctypes ocamlPackages.ctypes-foreign + rnt ppx_protocol_conv ppx_protocol_conv_xml_light ]; @@ -197,56 +158,25 @@ @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 .# - # $ nix develop .# --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.sha ocamlPackages.ctypes ocamlPackages.ctypes-foreign + rnt ocamlPackages.data-encoding ocamlPackages.ppx_inline_test ocamlPackages.ppx_deriving ocamlPackages.ppx_sexp_conv - # legacyPackages.nixfmt-classic ocamlPackages.lwt ocamlPackages.lwt-exit ocamlPackages.batteries @@ -254,18 +184,20 @@ ppx_protocol_conv ppx_protocol_conv_xml_light ocamlPackages.earlybird - # Formal verification legacyPackages.coq legacyPackages.coqPackages.stdlib legacyPackages.z3 ]; - - + shellHook = '' export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH:+$CAML_LD_LIBRARY_PATH:}$(ocamlfind query num)" + export RNT_ROOT="${rnt}" + export CPATH="${rnt}/include''${CPATH:+:$CPATH}" + export LIBRARY_PATH="${rnt}/lib''${LIBRARY_PATH:+:$LIBRARY_PATH}" + export DYLD_LIBRARY_PATH="${rnt}/lib''${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" + export LD_LIBRARY_PATH="${rnt}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" ''; - # Tools from packages inputsFrom = [ self.packages.${system}.relational_engine ]; }; }; -- cgit v1.2.3