Skip to content

Commit

Permalink
chore(nix): switch to flakes and nixpkgs (#1041)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Jun 24, 2024
1 parent 7020e63 commit 762a0d7
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 3,972 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ jobs:
NIXPKGS_ALLOW_INSECURE: 1
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true
- uses: cachix/install-nix-action@v13
- uses: cachix/install-nix-action@V27
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: |
nix-shell --command "dune runtest --profile=dev cohttp cohttp-async cohttp-curl cohttp-curl-async cohttp-curl-lwt cohttp-lwt cohttp-lwt-unix cohttp-mirage cohttp-server-lwt-unix cohttp-top http"
nix-shell --command "dune build --profile=dev cohttp-lwt-jsoo"
nix develop -c dune runtest
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ clean:
fmt:
dune b @fmt --auto-promote

.PHONY: nix/opam-selection.nix
nix/opam-selection.nix:
nix-shell -A resolve default.nix

eio: #build eio
dune build cohttp-eio

eio-test:
dune runtest cohttp-eio

eio-shell: # nix-shell for eio dev
nix-shell -p gmp libev nmap curl
nix develop .#eio
3 changes: 0 additions & 3 deletions default.nix

This file was deleted.

113 changes: 113 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 138 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
description = "Cohttp Nix Flake";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nix-ocaml/nix-overlays";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs {
inherit system;
overlays = [
(final: prev: {
ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper: {
ctypes-foreign = osuper.ctypes-foreign.overrideAttrs (_: { doCheck = false; });
ctypes = osuper.ctypes.overrideAttrs (_: { doCheck = false; });
mdx = osuper.mdx.override {
# workaround for:
# https://github.com/NixOS/nixpkgs/pull/241476/commits/1ed74f3536d29e5635d7f47a1d7b82a89f5a8077
logs = oself.logs;
};
});
})
];
});
inherit (pkgs.ocamlPackages) buildDunePackage;
pkg = attrs: buildDunePackage ({
version = "n/a";
src = ./. ;
duneVersion = "3";
doCheck = true;
} // attrs);
ocamlformat = pkgs.ocamlformat_0_26_2;
in
with pkgs.ocamlPackages; rec {
packages = rec {
default = http;
http = pkg {
pname = "http";
checkInputs = [ alcotest base_quickcheck ppx_expect crowbar ];
};
cohttp = pkg {
pname = "cohttp";
checkInputs = [ fmt alcotest ];
propagatedBuildInputs = [
stringext http re uri uri-sexp logs sexplib0 ppx_sexp_conv
];
};
cohttp-top = pkg {
pname = "cohttp-top";
propagatedBuildInputs = [ cohttp ];
};
cohttp-curl = pkg {
pname = "cohttp-curl";
propagatedBuildInputs = [ ocurl http stringext ];
};
cohttp-curl-lwt = pkg {
pname = "cohttp-curl-lwt";
checkInputs = [ cohttp-lwt-unix cohttp cohttp-lwt conduit-lwt ounit uri ];
propagatedBuildInputs = [ ocurl http stringext lwt ];
};
cohttp-curl-async = pkg {
pname = "cohttp-curl-async";
checkInputs = [ uri fmt ounit alcotest cohttp-async ];
propagatedBuildInputs = [
ocurl http stringext cohttp-curl core core_unix
async_kernel async_unix
];
};
cohttp-lwt = pkg {
pname = "cohttp-lwt";
propagatedBuildInputs = [ http cohttp lwt sexplib0 ppx_sexp_conv logs uri ];
};
cohttp-lwt-jsoo = pkg {
pname = "cohttp-lwt-jsoo";
propagatedBuildInputs = [
http cohttp cohttp-lwt logs lwt lwt_ppx js_of_ocaml
js_of_ocaml-ppx js_of_ocaml-lwt
];
};
cohttp-async = pkg {
pname = "cohttp-async";
checkInputs = [ mirage-crypto ounit ];
propagatedBuildInputs = [ http cohttp async_kernel async_unix async base
core core_unix conduit-async magic-mime logs fmt sexplib0 ppx_sexp_conv
uri uri-sexp ipaddr
];
};
cohttp-lwt-unix = pkg {
pname = "cohttp-lwt-unix";
checkInputs = [ ounit ];
propagatedBuildInputs = [
http cohttp cohttp-lwt cmdliner lwt conduit-lwt
conduit-lwt-unix fmt ppx_sexp_conv magic-mime logs
];
};
cohttp-server-lwt-unix = pkg {
pname = "cohttp-server-lwt-unix";
checkInputs = [ conduit-lwt-unix cohttp-lwt cohttp-lwt-unix ];
propagatedBuildInputs = [ http lwt ];
};
cohttp-eio = pkg {
pname = "cohttp-eio";
checkInputs = [ alcotest eio_main mdx ppx_here
tls-eio
mirage-crypto-rng-eio
];
propagatedBuildInputs = [ cohttp eio eio_main logs uri fmt ptime http ];
};
cohttp-mirage = pkg {
pname = "cohttp-mirage";
propagatedBuildInputs = [
mirage-flow mirage-channel conduit conduit-mirage
mirage-kv lwt cohttp-lwt cstruct fmt astring magic-mime ppx_sexp_conv
];
};
cohttp-bench = pkg {
pname = "cohttp-bench";
buildInputs = [
core core_bench eio http cohttp cohttp-eio
cohttp-lwt-unix cohttp-server-lwt-unix cohttp-async
];
};
};
devShells.default = pkgs.mkShell {
inputsFrom = pkgs.lib.attrValues packages;
buildInputs = [ ocamlformat ] ++ (with pkgs.ocamlPackages; [
ocaml-lsp
]);
};
devShells.eio = pkgs.mkShell {
inputsFrom = [ cohttp-eio ];
buildInputs = [ ocamlformat ] ++ (with pkgs; [
ocamlPackages.ocaml-lsp gmp libev nmap curl
]);
};
});
}
50 changes: 0 additions & 50 deletions nix/default.nix

This file was deleted.

Loading

0 comments on commit 762a0d7

Please sign in to comment.