diff --git a/.nix/no-web.patch b/.nix/no-web.patch deleted file mode 100644 index 5342d8ee..00000000 --- a/.nix/no-web.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/compiler/catala_web_interpreter.ml b/compiler/catala_web_interpreter.ml -deleted file mode 100644 -index 3b8d660..0000000 ---- a/compiler/catala_web_interpreter.ml -+++ /dev/null -@@ -1,29 +0,0 @@ --open Driver --open Js_of_ocaml -- --let _ = -- Js.export_all -- (object%js -- method interpret -- (contents : Js.js_string Js.t) -- (scope : Js.js_string Js.t) -- (language : Js.js_string Js.t) -- (trace : bool) = -- driver -- (Contents (Js.to_string contents)) -- { -- Utils.Cli.debug = false; -- unstyled = false; -- wrap_weaved_output = false; -- avoid_exceptions = false; -- backend = "Interpret"; -- language = Some (Js.to_string language); -- max_prec_digits = None; -- closure_conversion = false; -- trace; -- disable_counterexamples = false; -- optimize = false; -- ex_scope = Some (Js.to_string scope); -- output_file = None; -- } -- end) -diff --git a/compiler/dune b/compiler/dune -index 2c5a1996..f6c38809 100644 ---- a/compiler/dune -+++ b/compiler/dune -@@ -19,16 +19,6 @@ - (libraries calendar zarith zarith_stubs_js) - (modules runtime)) - --(executable -- (name catala_web_interpreter) -- (modes byte js) -- (package catala) -- (public_name catala_web_interpreter) -- (modules catala_web_interpreter) -- (preprocess -- (pps js_of_ocaml-ppx)) -- (libraries catala.driver js_of_ocaml)) -- - (executable - (name catala) - (modes native js) diff --git a/.nix/packages.nix b/.nix/packages.nix new file mode 100644 index 00000000..3c34c98b --- /dev/null +++ b/.nix/packages.nix @@ -0,0 +1,19 @@ +{ ocamlPackages, fetchurl }: + +ocamlPackages.overrideScope' (self: super: { + cmdliner_1_1_0 = super.cmdliner.overrideAttrs (o: rec { + version = "1.1.0"; + src = fetchurl { + url = "https://erratique.ch/software/${o.pname}/releases/${o.pname }-${version}.tbz"; + sha256 = "sha256-irWd4HTlJSYuz3HMgi1de2GVL2qus0QjeCe1WdsSs8Q="; + }; + }); + alcotest = (super.alcotest.override { + cmdliner = self.cmdliner_1_1_0; + }).overrideAttrs (_: { + doCheck = false; + }); + bindlib = ocamlPackages.callPackage ./bindlib.nix { }; + unionfind = ocamlPackages.callPackage ./unionfind.nix { }; + ppx_yojson_conv = ocamlPackages.callPackage ./ppx_yojson_conv.nix { }; +}) diff --git a/.nix/ppx_yojson_conv.nix b/.nix/ppx_yojson_conv.nix new file mode 100644 index 00000000..6b5e14b3 --- /dev/null +++ b/.nix/ppx_yojson_conv.nix @@ -0,0 +1,20 @@ +{ lib, fetchurl, buildDunePackage, ppxlib, ppx_yojson_conv_lib, ppx_js_style }: + +buildDunePackage rec { + pname = "ppx_yojson_conv"; + version = "0.14.0"; + + minimumOCamlVersion = "4.0.8"; + + useDune2 = true; + + propagatedBuildInputs = [ + ppxlib ppx_yojson_conv_lib ppx_js_style + ]; + + src = fetchurl + { + url = "https://ocaml.janestreet.com/ocaml-core/v0.14/files/ppx_yojson_conv-v0.14.0.tar.gz"; + sha256 = "0ls6vzj7k0wrjliifqczs78anbc8b88as5w7a3wixfcs1gjfsp2w"; + }; +} diff --git a/default.nix b/default.nix index 0ae0adfd..72703841 100644 --- a/default.nix +++ b/default.nix @@ -7,7 +7,7 @@ , menhir , unionfind , bindlib -, cmdliner +, cmdliner_1_1_0 , re , zarith , zarith_stubs_js @@ -22,12 +22,13 @@ , ppx_deriving , z3 , alcotest +, ppx_yojson_conv , menhirLib ? null #for nixos-unstable compatibility. }: buildDunePackage rec { pname = "catala"; - version = "0.5.0"; + version = "0.6.0"; # TODO parse `catala.opam` with opam2json minimumOCamlVersion = "4.11"; @@ -40,7 +41,7 @@ buildDunePackage rec { sedlex_2 menhir menhirLib - cmdliner + cmdliner_1_1_0 re zarith zarith_stubs_js @@ -50,6 +51,7 @@ buildDunePackage rec { benchmark js_of_ocaml js_of_ocaml-ppx + ppx_yojson_conv camomile cppo z3 @@ -65,8 +67,6 @@ buildDunePackage rec { ] ++ (if isNull menhirLib then [ ] else [ menhirLib ]); doCheck = true; - patches = [ ./.nix/no-web.patch ]; - meta = with lib; { homepage = "https://catala-lang.org"; description = diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..d5f1ab2b --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1653581809, + "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..2136854e --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + inputs = { + flake-utils.url = github:numtide/flake-utils; + nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; + }; + + outputs = {nixpkgs, flake-utils, ...}: + let + systems = [ "x86_64-linux" ]; + in flake-utils.lib.eachSystem systems (system: + let + pkgs = import nixpkgs { inherit system; }; + ocamlPackages = pkgs.callPackage ./.nix/packages.nix {}; + in + rec { + packages = { + catala = ocamlPackages.callPackage ./. {}; + }; + defaultPackage = packages.catala; + devShell = pkgs.mkShell { + inputsFrom = [packages.catala]; + buildInputs = [ + pkgs.inotify-tools + ocamlPackages.merlin + pkgs.ocamlformat + ocamlPackages.ocp-indent + ocamlPackages.utop + ocamlPackages.ocaml-lsp + ]; + }; + } + ); +} diff --git a/release.nix b/release.nix deleted file mode 100644 index f1859d38..00000000 --- a/release.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs ? import { } }: - -with pkgs; -ocamlPackages.callPackage ./. { - bindlib = ocamlPackages.callPackage ./.nix/bindlib.nix { }; - unionfind = ocamlPackages.callPackage ./.nix/unionfind.nix { }; -} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 9470086e..00000000 --- a/shell.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs ? import { } }: - -with pkgs; -let - pkg = ocamlPackages.callPackage ./. { - bindlib = ocamlPackages.callPackage ./.nix/bindlib.nix { }; - unionfind = ocamlPackages.callPackage ./.nix/unionfind.nix { }; - }; -in mkShell { - inputsFrom = [ pkg ]; - buildInputs = pkg.propagatedBuildInputs ++ [ - inotify-tools - ocamlPackages.merlin - ocamlformat - ocamlPackages.ocp-indent - ocamlPackages.utop - ocamlPackages.ocaml-lsp - ]; -}