Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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 = "25.10.1";
14 format = "setuptools";
15
16 src = fetchFromGitHub {
17 owner = "truenas";
18 repo = "py-libzfs";
19 rev = "TS-${version}";
20 hash = "sha256-kme5qUG0Nsya8HxU/oMHP1AidoMMOob/EON8sZMzKKI=";
21 };
22
23 patches = [
24 # Upstream has open PR. Debian uses the patch.
25 # https://github.com/truenas/py-libzfs/pull/277
26 (fetchpatch2 {
27 url = "https://salsa.debian.org/python-team/packages/py-libzfs/-/raw/debian/0.0+git20240510.5ae7d5e-1/debian/patches/fix-compilation-on-gcc-14.patch";
28 hash = "sha256-KLxRx2k1LQGtmzMqJe9b84ApOnIXn8ZeBZun5BAxEjc=";
29 })
30 ];
31
32 build-system = [ cython_0 ];
33 buildInputs = [ zfs ];
34
35 # Passing CFLAGS in configureFlags does not work, see https://github.com/truenas/py-libzfs/issues/107
36 postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
37 substituteInPlace configure \
38 --replace-fail \
39 'CFLAGS="-DCYTHON_FALLTHROUGH"' \
40 'CFLAGS="-DCYTHON_FALLTHROUGH -I${zfs.dev}/include/libzfs -I${zfs.dev}/include/libspl"' \
41 --replace-fail 'zof=false' 'zof=true'
42 '';
43
44 pythonImportsCheck = [ "libzfs" ];
45
46 meta = {
47 description = "Python libzfs bindings";
48 homepage = "https://github.com/truenas/py-libzfs";
49 license = lib.licenses.bsd2;
50 maintainers = with lib.maintainers; [ chuangzhu ];
51 # The project also supports macOS (OpenZFS on OSX, O3X), FreeBSD and OpenSolaris
52 # I don't have a machine to test out, thus only packaged for Linux
53 platforms = lib.platforms.linux;
54 };
55}