From 6dfbb7c89f716038a2567d6eb6f7f86e52cc876f Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 31 Jul 2023 16:13:23 +0200 Subject: [PATCH] ocamlPackages.ptime: use `finalAttrs` pattern --- .../ocaml-modules/ptime/default.nix | 35 ++++++++++++------- pkgs/top-level/ocaml-packages.nix | 5 ++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pkgs/development/ocaml-modules/ptime/default.nix b/pkgs/development/ocaml-modules/ptime/default.nix index d5e6264b1f11..9c1914b0f322 100644 --- a/pkgs/development/ocaml-modules/ptime/default.nix +++ b/pkgs/development/ocaml-modules/ptime/default.nix @@ -1,28 +1,40 @@ -{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg +{ stdenv +, lib +, fetchurl +, ocaml +, findlib +, ocamlbuild +, topkg }: -lib.throwIfNot (lib.versionAtLeast ocaml.version "4.08") - "ptime is not available for OCaml ${ocaml.version}" - -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { version = "1.1.0"; pname = "ocaml${ocaml.version}-ptime"; src = fetchurl { - url = "https://erratique.ch/software/ptime/releases/ptime-${version}.tbz"; - sha256 = "sha256-y/WxVFT7JxBeLDNAI+HhHY+TnXF4hw9cvo7SbfcBPrE="; + url = "https://erratique.ch/software/ptime/releases/ptime-${finalAttrs.version}.tbz"; + hash = "sha256-y/WxVFT7JxBeLDNAI+HhHY+TnXF4hw9cvo7SbfcBPrE="; }; - nativeBuildInputs = [ ocaml findlib ocamlbuild topkg ]; - buildInputs = [ topkg ]; + nativeBuildInputs = [ + findlib + ocaml + ocamlbuild + topkg + ]; + + buildInputs = [ + topkg + ]; strictDeps = true; inherit (topkg) buildPhase installPhase; meta = { - homepage = "https://erratique.ch/software/ptime"; description = "POSIX time for OCaml"; + homepage = "https://erratique.ch/software/ptime"; + license = lib.licenses.isc; longDescription = '' Ptime has platform independent POSIX time support in pure OCaml. It provides a type to represent a well-defined range of POSIX timestamps @@ -35,7 +47,6 @@ stdenv.mkDerivation rec { Ptime is not a calendar library. ''; - license = lib.licenses.isc; maintainers = with lib.maintainers; [ sternenseemann ]; }; -} +}) diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 85c79981cc00..02e659de3a99 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -1433,7 +1433,10 @@ let psq = callPackage ../development/ocaml-modules/psq { }; - ptime = callPackage ../development/ocaml-modules/ptime { }; + ptime = + if lib.versionAtLeast ocaml.version "4.08" + then callPackage ../development/ocaml-modules/ptime { } + else null; ptmap = callPackage ../development/ocaml-modules/ptmap { };