From 499149ef950c54c669e4a1d6cdf6f4cc121f543e Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 4 Jul 2023 15:01:03 +0200 Subject: [PATCH 1/3] ocamlPackages.b0: Init at 0.0.5 The recent package is a dependency for odig. --- pkgs/development/ocaml-modules/b0/default.nix | 46 +++++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 2 + 2 files changed, 48 insertions(+) create mode 100644 pkgs/development/ocaml-modules/b0/default.nix diff --git a/pkgs/development/ocaml-modules/b0/default.nix b/pkgs/development/ocaml-modules/b0/default.nix new file mode 100644 index 000000000000..e3c21c31e689 --- /dev/null +++ b/pkgs/development/ocaml-modules/b0/default.nix @@ -0,0 +1,46 @@ +{ lib, stdenv, fetchurl, ocaml, findlib, topkg, ocamlbuild, cmdliner }: + +let + +in lib.throwIfNot (lib.versionAtLeast ocaml.version "4.08") +"b0 is not available for OCaml ${ocaml.version}" + +stdenv.mkDerivation rec { + + pname = "ocaml${ocaml.version}-b0"; + version = "0.0.5"; + + src = fetchurl { + url = "${meta.homepage}/releases/b0-${version}.tbz"; + sha256 = "sha256-ty04JQcP4RCme/VQw0ko2IBebWWX5cBU6nRTTeV1I/I="; + }; + + strictDeps = true; + + nativeBuildInputs = [ ocaml findlib ocamlbuild topkg ]; + buildInputs = [ topkg cmdliner ]; + + inherit (topkg) buildPhase installPhase; + + meta = with lib; { + description = "Software construction and deployment kit"; + longDescription = '' + WARNING this package is unstable and work in progress, do not depend on + it. + B0 describes software construction and deployments using modular and + customizable definitions written in OCaml. B0 describes: + * Build environments. + * Software configuration, build and testing. + * Source and binary deployments. + * Software life-cycle procedures. + B0 also provides the B00 build library which provides abitrary build + abstraction with reliable and efficient incremental rebuilds. The B00 + library can be – and has been – used on its own to devise domain specific + build systems. + ''; + homepage = "https://erratique.ch/software/b0"; + inherit (ocaml.meta) platforms; + license = licenses.isc; + maintainers = [ maintainers.Julow ]; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index e6cbbec2da74..0767b58a43af 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -60,6 +60,8 @@ let ### B ### + b0 = callPackage ../development/ocaml-modules/b0 { }; + bap = janeStreet_0_15.bap; base64 = callPackage ../development/ocaml-modules/base64 { }; From 187d777aada735b5793f78b9b62726ce0752d739 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 4 Jul 2023 15:54:16 +0200 Subject: [PATCH 2/3] ocamlPackages.buildTopkgPackage: Added This function helps building an OCaml package that builds with topkg. There are currently many such packages in nixpkgs and this function would greatly simplify adding more. This is heavily inspired by `ocamlPackages.buildDunePackage`. --- pkgs/build-support/ocaml/topkg.nix | 28 ++++++++++++++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/build-support/ocaml/topkg.nix diff --git a/pkgs/build-support/ocaml/topkg.nix b/pkgs/build-support/ocaml/topkg.nix new file mode 100644 index 000000000000..73be5815e44c --- /dev/null +++ b/pkgs/build-support/ocaml/topkg.nix @@ -0,0 +1,28 @@ +{ lib, stdenv, fetchurl, ocaml, findlib, topkg, ocamlbuild, cmdliner, odoc, b0 +}: + +{ pname, version, nativeBuildInputs ? [ ], buildInputs ? [ ], ... }@args: + +lib.throwIf (args ? minimalOCamlVersion + && lib.versionOlder ocaml.version args.minimalOCamlVersion) +"${pname}-${version} is not available for OCaml ${ocaml.version}" + +stdenv.mkDerivation ({ + + dontAddStaticConfigureFlags = true; + configurePlatforms = [ ]; + strictDeps = true; + inherit (topkg) buildPhase installPhase; + +} // (builtins.removeAttrs args [ "minimalOCamlVersion" ]) // { + + name = "ocaml${ocaml.version}-${pname}-${version}"; + + nativeBuildInputs = [ ocaml findlib ocamlbuild topkg ] ++ nativeBuildInputs; + buildInputs = [ topkg ] ++ buildInputs; + + meta = (args.meta or { }) // { + platforms = args.meta.platforms or ocaml.meta.platforms; + }; + +}) diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 0767b58a43af..649463029c94 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -1890,6 +1890,8 @@ let buildOasisPackage = callPackage ../build-support/ocaml/oasis.nix { }; + buildTopkgPackage = callPackage ../build-support/ocaml/topkg.nix { }; + # Apps from all-packages, to be eventually removed google-drive-ocamlfuse = callPackage ../applications/networking/google-drive-ocamlfuse { }; From b94953dbd41c3e6e371a9ba2fe97e7c7750b92a8 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 4 Jul 2023 15:57:37 +0200 Subject: [PATCH 3/3] odig: Init at 0.0.9 Odig is a tool for building the documentation of OCaml libraries. It is described with the recent `buildTopkgPackage` function. --- .../ocaml-modules/odig/default.nix | 25 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ pkgs/top-level/ocaml-packages.nix | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 pkgs/development/ocaml-modules/odig/default.nix diff --git a/pkgs/development/ocaml-modules/odig/default.nix b/pkgs/development/ocaml-modules/odig/default.nix new file mode 100644 index 000000000000..5ea3730c7ff4 --- /dev/null +++ b/pkgs/development/ocaml-modules/odig/default.nix @@ -0,0 +1,25 @@ +{ lib, stdenv, fetchurl, buildTopkgPackage, cmdliner, odoc, b0 }: + +buildTopkgPackage rec { + pname = "odig"; + version = "0.0.9"; + + src = fetchurl { + url = "${meta.homepage}/releases/odig-${version}.tbz"; + sha256 = "sha256-sYKvGYkxeF5FmrNQdOyMAtlsJqhlmUESi9SkPn/cjM4="; + }; + + buildInputs = [ cmdliner odoc b0 ]; + + meta = with lib; { + description = "Lookup documentation of installed OCaml packages"; + longDescription = '' + odig is a command line tool to lookup documentation of installed OCaml + packages. It shows package metadata, readmes, change logs, licenses, + cross-referenced `odoc` API documentation and manuals. + ''; + homepage = "https://erratique.ch/software/odig"; + license = licenses.isc; + maintainers = [ maintainers.Julow ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fcd85ba8296f..c1d37972ab7a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16863,6 +16863,8 @@ with pkgs; ocamlformat_0_22_4 ocamlformat_0_23_0 ocamlformat_0_24_1 ocamlformat_0_25_1 ocamlformat_0_26_0; + inherit (ocamlPackages) odig; + orc = callPackage ../development/compilers/orc { }; orocos-kdl = callPackage ../development/libraries/orocos-kdl { }; diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 649463029c94..71fc1d9a460f 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -1332,6 +1332,8 @@ let odate = callPackage ../development/ocaml-modules/odate { }; + odig = callPackage ../development/ocaml-modules/odig { }; + odoc = callPackage ../development/ocaml-modules/odoc { }; odoc-parser = callPackage ../development/ocaml-modules/odoc-parser { };