From cc783c157f31e7e713c8b83be67449b1859dac27 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Wed, 20 Dec 2023 20:43:25 -0600 Subject: Initial commit --- flake.nix | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..20b8532 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + opam-nix.url = "github:tweag/opam-nix"; + opam-repository = { + url = "github:ocaml/opam-repository"; + flake = false; + }; + opam-nix.inputs.opam-repository.follows = "opam-repository"; + opam-nix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, opam-nix, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + inherit (opam-nix.lib.${system}) + buildOpamProject + materializedDefsToScope + materializeOpamProject'; + package = "ann_bloop"; + devPackagesQuery = { + ocaml-lsp-server = "*"; + ocamlformat = "*"; + # 1.9.6 fails to build + ocamlfind = "1.9.5"; + utop = "*"; + }; + query = { + ocaml-base-compiler = "*"; + }; + overlay = final: prev: { + "${package}" = prev.${package}.overrideAttrs (_: { + # override derivation attributes, e.g. add additional dependacies + buildInputs = [ + pkgs."gmp" + pkgs."libev" + pkgs."openssl" + ]; + }); + }; + devBuildInputs = [ pkgs.ocamlPackages.ocamlformat ]; + resolved-scope = + let scope = buildOpamProject { } package ./. query; + in scope.overrideScope' overlay; + materialized-scope = + let scope = materializedDefsToScope + { sourceMap.${package} = ./.; } ./package-defs.json; + in scope.overrideScope' overlay; + in rec { + packages = { + resolved = resolved-scope; + materialized = materialized-scope; + # to generate: + # cat $(nix eval .#package-defs --raw) > package-defs.json + package-defs = materializeOpamProject' { } ./. query; + }; + defaultPackage = packages.materialized.${package}; + devShells.default = pkgs.mkShell { + inputsFrom = [ defaultPackage ]; + buildInputs = devBuildInputs; + }; + } + ); +} -- cgit v1.2.3