depot/third_party/nixpkgs/pkgs/by-name/li/libnbd/package.nix
Default email 555cd8a8f9 Project import generated by Copybara.
GitOrigin-RevId: 5633bcff0c6162b9e4b5f1264264611e950c8ec7
2024-10-09 18:51:18 +02:00

99 lines
2.7 KiB
Nix

{
lib,
stdenv,
fetchurl,
bash-completion,
pkg-config,
perl,
buildPythonBindings ? false,
buildOcamlBindings ? false,
ocamlPackages,
python3,
libxml2,
fuse,
fuse3,
gnutls,
autoreconfHook,
}:
lib.throwIf (buildOcamlBindings && !lib.versionAtLeast ocamlPackages.ocaml.version "4.05")
"OCaml binding are not available for OCaml < 4.05"
stdenv.mkDerivation rec {
pname = "libnbd";
version = "1.20.2";
src = fetchurl {
url = "https://download.libguestfs.org/libnbd/${lib.versions.majorMinor version}-stable/${pname}-${version}.tar.gz";
hash = "sha256-7DgviwGPPLccTPvomyH+0CMknXmR2wENsxpXD97OP84=";
};
nativeBuildInputs =
[
bash-completion
pkg-config
perl
autoreconfHook
]
++ lib.optionals buildPythonBindings [ python3 ]
++ lib.optionals buildOcamlBindings (
with ocamlPackages;
[
findlib
ocaml
]
);
buildInputs = [
fuse
fuse3
gnutls
libxml2
];
postPatch = lib.optionalString buildOcamlBindings ''
substituteInPlace ocaml/Makefile.am \
--replace-fail '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib'
'';
configureFlags = lib.optionals buildPythonBindings [
"--with-python-installdir=${placeholder "out"}/${python3.sitePackages}"
];
installFlags = [ "bashcompdir=$(out)/share/bash-completion/completions" ];
postInstall = lib.optionalString buildPythonBindings ''
LIBNBD_PYTHON_METADATA='${placeholder "out"}/${python3.sitePackages}/nbd-${version}.dist-info/METADATA'
install -Dm644 -T ${./libnbd-metadata} $LIBNBD_PYTHON_METADATA
substituteAllInPlace $LIBNBD_PYTHON_METADATA
'';
meta = with lib; {
homepage = "https://gitlab.com/nbdkit/libnbd";
description = "Network Block Device client library in userspace";
longDescription = ''
NBD Network Block Device is a protocol for accessing Block Devices
(hard disks and disk-like things) over a Network. This is the NBD client
library in userspace, a simple library for writing NBD clients.
The key features are:
- Synchronous API for ease of use.
- Asynchronous API for writing non-blocking, multithreaded clients. You
can mix both APIs freely.
- High performance.
- Minimal dependencies for the basic library.
- Well-documented, stable API.
- Bindings in several programming languages.
- Shell (nbdsh) for command line and scripting.
'';
license = with licenses; lgpl21Plus;
maintainers = with maintainers; [
AndersonTorres
humancalico
];
platforms = with platforms; linux;
};
}
# TODO: package the 1.6-stable version too
# TODO: git version needs ocaml
# TODO: bindings for go