diff options
| author | Quentin Aristote <quentin@aristote.fr> | 2021-12-11 17:13:53 +0100 |
|---|---|---|
| committer | Quentin Aristote <quentin@aristote.fr> | 2021-12-11 17:13:53 +0100 |
| commit | 3db139457488215714d0147a3c8313d496eb17b2 (patch) | |
| tree | c4b868e0c992b408f67e03af5b9284fe25ddf593 | |
| parent | 3199ee20e62c84ea7a4376a65c22b50c24ca4fbf (diff) | |
ocaml : add version option
| -rw-r--r-- | modules/ocaml.nix | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/modules/ocaml.nix b/modules/ocaml.nix index d5393b0..e6a9266 100644 --- a/modules/ocaml.nix +++ b/modules/ocaml.nix @@ -4,21 +4,20 @@ with lib; with builtins; let cfg = config.ocaml; - ocamlVersion = (parseDrvName cfg.ocamlPackages.ocaml.name).version; tuaregPackages = optionals cfg.tuareg.enable (with pkgs; [ ocamlformat opam ]) ++ (with cfg.ocamlPackages; [ merlin ocp-indent utop ]); userPackages = cfg.packages cfg.ocamlPackages; ocamlBuildInputs = (with cfg.ocamlPackages; [ ocaml findlib ]) ++ (with pkgs; - if versionAtLeast ocamlVersion "4.12" then + if versionAtLeast cfg.version "4.12" then [ dune_2 ] else - (optional (versionAtLeast ocamlVersion "4.02") dune_1)) ++ tuaregPackages + (optional (versionAtLeast cfg.version "4.02") dune_1)) ++ tuaregPackages ++ userPackages; ocamlInit = pkgs.writeText "ocamlinit" ('' let () = - try Topdirs.dir_directory "${cfg.ocamlPackages.findlib}/lib/ocaml/${ocamlVersion}/site-lib" + try Topdirs.dir_directory "${cfg.ocamlPackages.findlib}/lib/ocaml/${cfg.version}/site-lib" with Not_found -> () ;; #use "topfind";; @@ -29,6 +28,17 @@ let in { options.ocaml = { enable = mkEnableOption { name = "ocaml"; }; + version = mkOption { + type = types.uniq types.str; + default = (builtins.parseDrvName cfg.ocamlPackages.ocaml.name).version; + defaultText = literalExample + "(builtins.parseDrvName config.ocaml.ocamlPackages.ocaml.name).version"; + description = '' + The version of OCaml. This option only exist for propagating the version + of OCaml through the configuration. As such, it should not be set manually + but through the ocamlPackages option. + ''; + }; ocamlPackages = mkOption { type = types.lazyAttrsOf types.package; default = pkgs.ocamlPackages; |
