1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 fetchpatch2, 7 cython_0, 8 zfs, 9}: 10 11buildPythonPackage rec { 12 pname = "py-libzfs"; 13 version = "24.04.0"; 14 format = "setuptools"; 15 16 src = fetchFromGitHub { 17 owner = "truenas"; 18 repo = pname; 19 rev = "TS-${version}"; 20 hash = "sha256-Uiu0RNE06++iNWUNcKpbZvreT2D7/EqHlFZJXKe3F4A="; 21 }; 22 23 patches = [ 24 (fetchpatch2 { 25 url = "https://github.com/truenas/py-libzfs/commit/b5ffe1f1d6097df6e2f5cc6dd3c968872ec60804.patch"; 26 hash = "sha256-6r5hQ/o7c4vq4Tfh0l1WbeK3AuPvi+1wzkwkIn1qEes="; 27 }) 28 ]; 29 30 build-system = [ cython_0 ]; 31 buildInputs = [ zfs ]; 32 33 # Passing CFLAGS in configureFlags does not work, see https://github.com/truenas/py-libzfs/issues/107 34 postPatch = lib.optionalString stdenv.hostPlatform.isLinux '' 35 substituteInPlace configure \ 36 --replace-fail \ 37 'CFLAGS="-DCYTHON_FALLTHROUGH"' \ 38 'CFLAGS="-DCYTHON_FALLTHROUGH -I${zfs.dev}/include/libzfs -I${zfs.dev}/include/libspl"' \ 39 --replace-fail 'zof=false' 'zof=true' 40 ''; 41 42 pythonImportsCheck = [ "libzfs" ]; 43 44 meta = with lib; { 45 description = "Python libzfs bindings"; 46 homepage = "https://github.com/truenas/py-libzfs"; 47 license = licenses.bsd2; 48 maintainers = with maintainers; [ chuangzhu ]; 49 # The project also supports macOS (OpenZFS on OSX, O3X), FreeBSD and OpenSolaris 50 # I don't have a machine to test out, thus only packaged for Linux 51 platforms = platforms.linux; 52 }; 53}