diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 78 |
1 files changed, 33 insertions, 45 deletions
@@ -2,65 +2,53 @@ 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"; + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.follows = "opam-nix/nixpkgs"; }; - - outputs = { self, nixpkgs, opam-nix, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: + outputs = { self, flake-utils, opam-nix, nixpkgs }@inputs: + let package = "fixgen"; + in 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"; + on = opam-nix.lib.${system}; devPackagesQuery = { + # You can add "development" packages here. They will get added to the devShell automatically. ocaml-lsp-server = "*"; ocamlformat = "*"; - # 1.9.6 fails to build ocamlfind = "1.9.5"; utop = "*"; }; - query = { + query = devPackagesQuery // { + ## You can force versions of certain packages here, e.g: + ## - force the ocaml compiler to be taken from opam-repository: ocaml-base-compiler = "*"; + ## - or force the compiler to be taken from nixpkgs and be a certain version: + # ocaml-system = "4.14.0"; + ## - or force ocamlfind to be a certain version: }; + scope = on.buildOpamProject' { } ./. query; overlay = final: prev: { - "${package}" = prev.${package}.overrideAttrs (_: { - # override derivation attributes, e.g. add additional dependacies - buildInputs = [ - pkgs."gmp" - pkgs."libev" - pkgs."openssl" - ]; + # You can add overrides here + ${package} = prev.${package}.overrideAttrs (_: { + # Prevent the ocaml dependencies from leaking into dependent environments + doNixSupport = false; }); }; - 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}; + scope' = scope.overrideScope' overlay; + # The main package containing the executable + main = scope'.${package}; + # Packages from devPackagesQuery + devPackages = builtins.attrValues + (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope'); + in { + legacyPackages = scope'; + + packages.default = main; + devShells.default = pkgs.mkShell { - inputsFrom = [ defaultPackage ]; - buildInputs = devBuildInputs; + inputsFrom = [ main ]; + buildInputs = devPackages ++ [ + ]; }; - } - ); + }); } |