8 buildPythonBindings ? false,
9 buildOcamlBindings ? false,
19 lib.throwIf (buildOcamlBindings && !lib.versionAtLeast ocamlPackages.ocaml.version "4.05")
20 "OCaml binding are not available for OCaml < 4.05"
22 stdenv.mkDerivation rec {
27 url = "https://download.libguestfs.org/libnbd/${lib.versions.majorMinor version}-stable/${pname}-${version}.tar.gz";
28 hash = "sha256-7DgviwGPPLccTPvomyH+0CMknXmR2wENsxpXD97OP84=";
38 ++ lib.optionals buildPythonBindings [ python3 ]
39 ++ lib.optionals buildOcamlBindings (
54 postPatch = lib.optionalString buildOcamlBindings ''
55 substituteInPlace ocaml/Makefile.am \
56 --replace-fail '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib'
59 configureFlags = lib.optionals buildPythonBindings [
60 "--with-python-installdir=${placeholder "out"}/${python3.sitePackages}"
63 installFlags = [ "bashcompdir=$(out)/share/bash-completion/completions" ];
65 postInstall = lib.optionalString buildPythonBindings ''
66 LIBNBD_PYTHON_METADATA='${placeholder "out"}/${python3.sitePackages}/nbd-${version}.dist-info/METADATA'
67 install -Dm644 -T ${./libnbd-metadata} $LIBNBD_PYTHON_METADATA
68 substituteAllInPlace $LIBNBD_PYTHON_METADATA
72 homepage = "https://gitlab.com/nbdkit/libnbd";
73 description = "Network Block Device client library in userspace";
75 NBD — Network Block Device — is a protocol for accessing Block Devices
76 (hard disks and disk-like things) over a Network. This is the NBD client
77 library in userspace, a simple library for writing NBD clients.
80 - Synchronous API for ease of use.
81 - Asynchronous API for writing non-blocking, multithreaded clients. You
82 can mix both APIs freely.
84 - Minimal dependencies for the basic library.
85 - Well-documented, stable API.
86 - Bindings in several programming languages.
87 - Shell (nbdsh) for command line and scripting.
89 license = with licenses; lgpl21Plus;
90 maintainers = with maintainers; [
94 platforms = with platforms; linux;
97 # TODO: package the 1.6-stable version too
98 # TODO: git version needs ocaml
99 # TODO: bindings for go