1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, cython
6, zfs
7}:
8
9buildPythonPackage rec {
10 pname = "py-libzfs";
11 version = "22.02.4";
12
13 src = fetchFromGitHub {
14 owner = "truenas";
15 repo = pname;
16 rev = "TS-${version}";
17 sha256 = "sha256-BJG+cw07Qu4aL99pVKNd7JAgr+w/6Uv2eI46EB615/I=";
18 };
19
20 nativeBuildInputs = [ cython ];
21 buildInputs = [ zfs ];
22
23 # Passing CFLAGS in configureFlags does not work, see https://github.com/truenas/py-libzfs/issues/107
24 postPatch = lib.optionalString stdenv.isLinux ''
25 substituteInPlace configure \
26 --replace \
27 'CFLAGS="-DCYTHON_FALLTHROUGH"' \
28 'CFLAGS="-DCYTHON_FALLTHROUGH -I${zfs.dev}/include/libzfs -I${zfs.dev}/include/libspl"' \
29 --replace 'zof=false' 'zof=true'
30 '';
31
32 pythonImportsCheck = [ "libzfs" ];
33
34 meta = with lib; {
35 description = "Python libzfs bindings";
36 homepage = "https://github.com/truenas/py-libzfs";
37 license = licenses.bsd2;
38 maintainers = with maintainers; [ chuangzhu ];
39 # The project also supports macOS (OpenZFS on OSX, O3X), FreeBSD and OpenSolaris
40 # I don't have a machine to test out, thus only packaged for Linux
41 platforms = platforms.linux;
42 };
43}
44