Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydra evaluation errors #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
_build
*.install
*.merlin

# nix build
/result*
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Online documentation is available [here](https://mirage.github.io/bloomf/).

Alternatively, you can build from sources with `make` or `dune build`.

### Nix
You can buid the project for different OCaml versions using the [Nix package
manager][nix]. To list the supported versions, run `nix flake show`. For
example, to build the project for OCaml version 4.12, run `nix build
'.#ocamlPackages_4_12-p2pcollab-bloomf'`.

[nix]: https://nixos.org/

## Tests

Some of the tests, measuring false positive rate or size estimation, might fail
Expand Down
79 changes: 79 additions & 0 deletions flake.lock

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

85 changes: 85 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
description = "Efficient Bloom filters for OCaml";

inputs = {
nixpkgs.url = "nixpkgs/nixos-21.05";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
nix-utils = {
url = "sourcehut:~ilkecan/nix-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, nix-utils, ... }@inputs:
let
inherit (builtins)
attrNames
attrValues
;
inherit (flake-utils.lib)
defaultSystems
eachSystem
;
nix-filter = inputs.nix-filter.lib;
inherit (nix-utils.lib)
createOcamlOverlays
getOcamlPackages
getOcamlPackagesFrom
getUnstableVersion
;

supportedSystems = defaultSystems;
commonArgs = {
version = getUnstableVersion self.lastModifiedDate;
homepage = "https://p2pcollab.net/";
downloadPage = "https://github.com/p2pcollab/bloomf/releases";
changelog = "https://raw.githubusercontent.com/p2pcollab/bloomf/master/CHANGES.md";
maintainers = [
{
name = "ilkecan bozdogan";
email = "[email protected]";
github = "ilkecan";
githubId = "40234257";
}
];
platforms = supportedSystems;
};

derivations = {
p2pcollab-bloomf = import ./nix/p2pcollab-bloomf.nix commonArgs;
};
in
{
overlays = createOcamlOverlays derivations { inherit nix-filter; };
overlay = self.overlays.ocamlPackages-p2pcollab-bloomf;
} // eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = attrValues self.overlays;
};

packageNames = attrNames derivations;
defaultOcamlPackages = getOcamlPackagesFrom pkgs packageNames "ocamlPackages";
in
rec {
checks = packages;

packages = getOcamlPackages pkgs packageNames;
defaultPackage = packages.ocamlPackages-p2pcollab-bloomf;

hydraJobs = {
build = defaultOcamlPackages;
};

devShell =
let
packages = attrValues defaultOcamlPackages;
in
pkgs.mkShell {
inherit packages;
inputsFrom = packages;
};
});
}
72 changes: 72 additions & 0 deletions nix/p2pcollab-bloomf.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{ version
, homepage
, downloadPage
, changelog
, maintainers
, platforms
, runFullTestSuite ? false
}:
{ lib
, nix-filter
, ocamlPackages
, ...
}:

let
inherit (nix-filter) inDirectory;

pname = "bloomf";
duneTestCommand = if runFullTestSuite then "build @runtest-rand" else "runtest";
in
ocamlPackages.buildDunePackage {
inherit pname version;

src = nix-filter {
root = ./..;
include = [
"${pname}.opam"
"dune-project"
(inDirectory "src")
(inDirectory "test")
];
name = "p2pcollab-${pname}";
};

minimumOCamlVersion = "4.03";
useDune2 = true;

dontPatch = true;
dontConfigure = true;

buildInputs = with ocamlPackages; [
bitv.out
];

doCheck = true;
checkInputs = with ocamlPackages; [
alcotest.out
];
checkPhase = ''
runHook preCheck
dune ${duneTestCommand} -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postCheck
'';

meta = {
description = "Efficient Bloom filters for OCaml";
longDescription =
"Bloom filters are memory and time efficient data structures allowing " +
"probabilistic membership queries in a set.\n" +
"A query negative result ensures that the element is not present in " +
"the set, while a positive result might be a false positive, i.e. the " +
"element might not be present and the BF membership query can return " +
"true anyway.\n" +
"Internal parameters of the BF allow to control its false positive " +
"rate depending on the expected number of elements in it.";

inherit homepage downloadPage changelog;

license = lib.licenses.mit;
inherit maintainers platforms;
};
}