From 3db139457488215714d0147a3c8313d496eb17b2 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sat, 11 Dec 2021 17:13:53 +0100 Subject: ocaml : add version option --- modules/ocaml.nix | 18 ++++++++++++++---- 1 file 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; -- cgit v1.2.3