diff --git a/pkgs/development/ocaml-modules/dream/default.nix b/pkgs/development/ocaml-modules/dream/default.nix new file mode 100644 index 0000000000000..d359935079381 --- /dev/null +++ b/pkgs/development/ocaml-modules/dream/default.nix @@ -0,0 +1,67 @@ +{ + lib, + buildDunePackage, + dream-pure, + lwt_ppx, + camlp-streams, + caqti-lwt, + cstruct, + digestif, + dream-httpaf, + graphql-lwt, + h2-lwt-unix, + httpun-lwt-unix, + httpun-ws, + lambdasoup, + lwt_ssl, + magic-mime, + markup, + mirage-clock, + mirage-crypto-rng, + mirage-crypto-rng-lwt, + multipart_form-lwt, + ssl, + unstrctrd, + uri, + yojson, +}: + +buildDunePackage { + pname = "dream"; + + inherit (dream-pure) version src; + + # Compatibility with httpun 0.2.0 and h2 0.13 + patches = [ ./httpun.patch ]; + + buildInputs = [ lwt_ppx ]; + + propagatedBuildInputs = [ + camlp-streams + caqti-lwt + cstruct + digestif + dream-httpaf + dream-pure + graphql-lwt + h2-lwt-unix + httpun-lwt-unix + httpun-ws + lambdasoup + lwt_ssl + magic-mime + markup + mirage-clock + mirage-crypto-rng + mirage-crypto-rng-lwt + multipart_form-lwt + ssl + unstrctrd + uri + yojson + ]; + + meta = dream-pure.meta // { + description = "Tidy, feature-complete Web framework"; + }; +} diff --git a/pkgs/development/ocaml-modules/dream/httpaf.nix b/pkgs/development/ocaml-modules/dream/httpaf.nix new file mode 100644 index 0000000000000..6ba186bceb7a7 --- /dev/null +++ b/pkgs/development/ocaml-modules/dream/httpaf.nix @@ -0,0 +1,23 @@ +{ + lib, + buildDunePackage, + dream-pure, + lwt_ppx, + httpun-ws, +}: + +buildDunePackage { + pname = "dream-httpaf"; + + inherit (dream-pure) version src; + + buildInputs = [ lwt_ppx ]; + propagatedBuildInputs = [ + dream-pure + httpun-ws + ]; + + meta = dream-pure.meta // { + description = "Shared http/af stack for Dream (server) and Hyper (client)"; + }; +} diff --git a/pkgs/development/ocaml-modules/dream/httpun.patch b/pkgs/development/ocaml-modules/dream/httpun.patch new file mode 100644 index 0000000000000..fe47b4e6ba450 --- /dev/null +++ b/pkgs/development/ocaml-modules/dream/httpun.patch @@ -0,0 +1,20 @@ +diff --git a/src/http/adapt.ml b/src/http/adapt.ml +index c6bd416..5b01e17 100644 +--- a/src/http/adapt.ml ++++ b/src/http/adapt.ml +@@ -74,7 +74,7 @@ let forward_body + response + (Httpun.Body.Writer.write_string body) + (Httpun.Body.Writer.write_bigstring body) +- (Httpun.Body.Writer.flush body) ++ (fun f -> Httpun.Body.Writer.flush body (fun _ -> f ())) + (fun _code -> Httpun.Body.Writer.close body) + + let forward_body_h2 +@@ -85,5 +85,5 @@ let forward_body_h2 + response + (H2.Body.Writer.write_string body) + (H2.Body.Writer.write_bigstring body) +- (H2.Body.Writer.flush body) ++ (fun f -> H2.Body.Writer.flush body (fun _ -> f ())) + (fun _code -> H2.Body.Writer.close body) diff --git a/pkgs/development/ocaml-modules/dream/pure.nix b/pkgs/development/ocaml-modules/dream/pure.nix new file mode 100644 index 0000000000000..884715f67cf32 --- /dev/null +++ b/pkgs/development/ocaml-modules/dream/pure.nix @@ -0,0 +1,38 @@ +{ + lib, + buildDunePackage, + fetchurl, + lwt_ppx, + base64, + hmap, + lwt, + ptime, + uri, +}: + +buildDunePackage rec { + pname = "dream-pure"; + version = "1.0.0-alpha8"; + + src = fetchurl { + url = "https://github.com/aantron/dream/releases/download/${version}/dream-${version}.tar.gz"; + hash = "sha256-I+2BKJDAP+XJl0pJYano5iEmvte8fX0UQLhGUslc8pY="; + }; + + buildInputs = [ lwt_ppx ]; + + propagatedBuildInputs = [ + base64 + hmap + lwt + ptime + uri + ]; + + meta = { + description = "Shared HTTP types for Dream (server) and Hyper (client)"; + homepage = "https://aantron.github.io/dream/"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.vbgl ]; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 73a1ce4898198..fcd91264cbb59 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -383,6 +383,12 @@ let dot-merlin-reader = callPackage ../development/tools/ocaml/merlin/dot-merlin-reader.nix { }; + dream = callPackage ../development/ocaml-modules/dream { }; + + dream-httpaf = callPackage ../development/ocaml-modules/dream/httpaf.nix { }; + + dream-pure = callPackage ../development/ocaml-modules/dream/pure.nix { }; + dscheck = callPackage ../development/ocaml-modules/dscheck { }; dssi = callPackage ../development/ocaml-modules/dssi { };