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

Fixed PsqK.adjust error and added flake. #3

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
\#*
_build
*.install
result
3 changes: 3 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = builtins.fetchGit ./.;
}).defaultNix
41 changes: 41 additions & 0 deletions flake.lock

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

106 changes: 106 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
description = "FSQ library in OCaml";

inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
# flake-utils.url = "github:numtide/flake-utils";

# fsq-src = {
# url = github:p2pcollab/ocaml-fsq;
# flake = false;
# };
};

outputs = { self, nixpkgs, flake-utils }:
let
# Generate a user-friendly version numer.
# version = builtins.substring 0 8 fsq-src.lastModifiedDate;

supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"armv7l-linux"
"x86_64-darwin"
"aarch64-darwin"
];

supportedOcamlPackages = [
"ocamlPackages_4_10"
"ocamlPackages_4_11"
"ocamlPackages_4_12"
"ocamlPackages_4_13"
];
defaultOcamlPackages = "ocamlPackages_4_13";

forAllOcamlPackages = nixpkgs.lib.genAttrs (supportedOcamlPackages ++ [ "ocamlPackages" ]);
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);

nixpkgsFor =
forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
});
in {
overlays.default = final: prev:
with final;
let mkOcamlPackages = prevOcamlPackages:
with prevOcamlPackages;
let ocamlPackages = {
inherit ocaml;
inherit findlib;
inherit ocamlbuild;
inherit opam-file-format;
inherit buildDunePackage;
inherit version;
name = "ocaml-packages";

fsq = buildDunePackage rec {
# inherit version;
minimumOCamlVersion = "4.10";
enableParallelBuilding = true;
pname = "fsq";
version = "0.0.1";
src = self;

useDune2 = true;
doCheck = true;

nativeBuildInputs = with ocamlPackages; [ odoc ];

propagatedBuildInputs = with ocamlPackages; [
psq
];

checkInputs = [
psq
ounit
];

meta = with lib; {
homepage = "https://github.com/p2pcollab/ocaml-fsq";
description = "FSQ is an OCaml implementation of functional fixed-size search queues, where old elements get popped from the queue when pushing to a queue that reached its maximum size.";
license = licenses.mpl20;
};
};
};
in ocamlPackages;
in
let allOcamlPackages =
forAllOcamlPackages (ocamlPackages:
mkOcamlPackages ocaml-ng.${ocamlPackages});
in
allOcamlPackages // {
ocamlPackages = allOcamlPackages.${defaultOcamlPackages};
};

packages =
forAllSystems (system:
forAllOcamlPackages (ocamlPackages:
nixpkgsFor.${system}.${ocamlPackages}));

defaultPackage =
forAllSystems (system:
nixpkgsFor.${system}.ocamlPackages.fsq);
};
}
2 changes: 1 addition & 1 deletion lib/fsq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module Make (K: Ordered) : S with type k = K.t = struct
PsqK.fold
(fun k p t ->
{ t with
psq = PsqK.adjust (fun p -> p - d) k t.psq;
psq = PsqK.adjust k (fun p -> p - d) t.psq;
maxp = p - d })
t t.psq in
let maxp = t.maxp + 1 in
Expand Down
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = builtins.fetchGit ./.;
}).shellNix