From b604e4aedde44c2d76b4904d4463e62dc58ef27f Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 20 May 2020 23:27:01 +0200 Subject: [PATCH] ocamlPackages.opam-repository: init at 2.0.7 --- .../ocaml-modules/opam-repository/default.nix | 24 +++++++++++++++ .../opam-repository/download-tool.patch | 29 +++++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 4 +++ 3 files changed, 57 insertions(+) create mode 100644 pkgs/development/ocaml-modules/opam-repository/default.nix create mode 100644 pkgs/development/ocaml-modules/opam-repository/download-tool.patch diff --git a/pkgs/development/ocaml-modules/opam-repository/default.nix b/pkgs/development/ocaml-modules/opam-repository/default.nix new file mode 100644 index 00000000000..1801a9e1c86 --- /dev/null +++ b/pkgs/development/ocaml-modules/opam-repository/default.nix @@ -0,0 +1,24 @@ +{ lib, buildDunePackage, unzip, opam-format, curl }: + +buildDunePackage rec { + pname = "opam-repository"; + + minimumOCamlVersion = "4.02"; + + inherit (opam-format) src version; + + patches = [ ./download-tool.patch ]; + postPatch = '' + substituteInPlace src/repository/opamRepositoryConfig.ml \ + --replace "SUBSTITUTE_NIXOS_CURL_PATH" "\"${curl}/bin/curl\"" + ''; + + nativeBuildInputs = [ unzip ]; + buildInputs = [ curl ]; + propagatedBuildInputs = [ opam-format ]; + + meta = opam-format.meta // { + description = "OPAM repository and remote sources handling, including curl/wget, rsync, git, mercurial, darcs backends"; + maintainers = with lib.maintainers; [ sternenseemann ]; + }; +} diff --git a/pkgs/development/ocaml-modules/opam-repository/download-tool.patch b/pkgs/development/ocaml-modules/opam-repository/download-tool.patch new file mode 100644 index 00000000000..5af720adca9 --- /dev/null +++ b/pkgs/development/ocaml-modules/opam-repository/download-tool.patch @@ -0,0 +1,29 @@ +diff --git a/src/repository/opamRepositoryConfig.ml b/src/repository/opamRepositoryConfig.ml +index c2954c1d..528fc621 100644 +--- a/src/repository/opamRepositoryConfig.ml ++++ b/src/repository/opamRepositoryConfig.ml +@@ -27,23 +27,7 @@ type 'a options_fun = + 'a + + let default = { +- download_tool = lazy ( +- try +- let tools = +- if OpamStd.Sys.(os () = Darwin) +- then ["wget", `Default; "curl", `Curl] +- else ["curl", `Curl; "wget", `Default] +- in +- let cmd, kind = +- List.find (fun (c,_) -> OpamSystem.resolve_command c <> None) tools +- in +- [ CIdent cmd, None ], kind +- with Not_found -> +- OpamConsole.error_and_exit `Configuration_error +- "Could not find a suitable download command. Please make sure you \ +- have either \"curl\" or \"wget\" installed, or specify a custom \ +- command through variable OPAMFETCH." +- ); ++ download_tool = lazy ([ CIdent SUBSTITUTE_NIXOS_CURL_PATH, None ], `Curl); + validation_hook = None; + retries = 3; + force_checksums = None; diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index ac0c5c7afb8..3eee3175ff9 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -686,6 +686,10 @@ let inherit (pkgs) unzip; }; + opam-repository = callPackage ../development/ocaml-modules/opam-repository { + inherit (pkgs) unzip; + }; + opium = callPackage ../development/ocaml-modules/opium { }; opium_kernel = callPackage ../development/ocaml-modules/opium_kernel { };