diff options
author | Marc Coquand <marcc@fastmail.fr> | 2023-12-04 19:33:34 -0600 |
---|---|---|
committer | Marc Coquand <marcc@fastmail.fr> | 2023-12-04 19:33:34 -0600 |
commit | 5802ae011093ca4e138ad82fcd0ee14bbcc6f20f (patch) | |
tree | ffd49a3d25fd61e35c1f379a9ce150908485cafc /flake.nix | |
parent | 2c6445f32891a5f7163fbf9b1d13613ba16832c7 (diff) | |
download | wormhole-5802ae011093ca4e138ad82fcd0ee14bbcc6f20f.tar.gz wormhole-5802ae011093ca4e138ad82fcd0ee14bbcc6f20f.tar.bz2 wormhole-5802ae011093ca4e138ad82fcd0ee14bbcc6f20f.zip |
Add nix
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7cc04fd --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + 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 = "wormhole"; + 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" + ]; + }); + }; + 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 = []; + }; + } + ); +} |