forked from mirage/bloomf
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add flake.nix #1
Open
ilkecan
wants to merge
1
commit into
lofirepo:master
Choose a base branch
from
ngi-nix:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
_build | ||
*.install | ||
*.merlin | ||
|
||
# nix build | ||
/result* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "git+https://git.sr.ht/~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; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that a multiline Nix string would work here, like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially adapted this method when I was trying to stay below a certain line length. But then I realized being strict about this kinda also harm the readability by creating verbose expressions. I relaxed the line length rule on most places but I guess
longDescription
must have stayed like that.The idea was to avoid line breaks that don't appear in the source text. When I do something like
the resulting string has unwanted line breaks.
I guess we could do
If the length of the line is not a problem.