From 0290bf69dd1d82b8f2d34b96a05a504d6c8a780b Mon Sep 17 00:00:00 2001 From: S-Vaes Date: Tue, 19 Jul 2022 14:17:47 +0200 Subject: [PATCH 1/3] Fixed PsqK.adjust error and added flake --- default.nix | 3 ++ flake.lock | 41 ++++++++++++++++++++ flake.nix | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/fsq.ml | 2 +- result | 1 + shell.nix | 3 ++ 6 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 120000 result create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..b22e926 --- /dev/null +++ b/default.nix @@ -0,0 +1,3 @@ +(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { + src = builtins.fetchGit ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c167b2b --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1657972522, + "narHash": "sha256-JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "07a2e6a4e31ea48408861607198972d60adaf4ad", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2b0e377 --- /dev/null +++ b/flake.nix @@ -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); + }; +} diff --git a/lib/fsq.ml b/lib/fsq.ml index 182399f..1452949 100644 --- a/lib/fsq.ml +++ b/lib/fsq.ml @@ -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 diff --git a/result b/result new file mode 120000 index 0000000..c3ddf8b --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/wjys1gxkm1l7d4qdjp3qi9va1spr7mkz-ocaml4.13.1-fsq-0.0.1 \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..db84e3d --- /dev/null +++ b/shell.nix @@ -0,0 +1,3 @@ +(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { + src = builtins.fetchGit ./.; +}).shellNix From ce0753b141752fbd2fd0a13a89d96b8e7a350ea0 Mon Sep 17 00:00:00 2001 From: S-Vaes Date: Tue, 19 Jul 2022 14:20:10 +0200 Subject: [PATCH 2/3] Removed result --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 06de165..ce4071f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ \#* _build *.install +result \ No newline at end of file From 1f8b034821b31d60e79051f615d4a1a26f296a7c Mon Sep 17 00:00:00 2001 From: S-Vaes Date: Tue, 19 Jul 2022 14:20:41 +0200 Subject: [PATCH 3/3] Removed result --- result | 1 - 1 file changed, 1 deletion(-) delete mode 120000 result diff --git a/result b/result deleted file mode 120000 index c3ddf8b..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/wjys1gxkm1l7d4qdjp3qi9va1spr7mkz-ocaml4.13.1-fsq-0.0.1 \ No newline at end of file