1{ fetchFromGitHub
2, json_c
3, keyutils
4, lib
5, meson
6, ninja
7, openssl
8, perl
9, pkg-config
10, python3
11, stdenv
12, swig
13, systemd
14, fetchpatch
15# ImportError: cannot import name 'mlog' from 'mesonbuild'
16, withDocs ? stdenv.hostPlatform.canExecute stdenv.buildPlatform
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "libnvme";
21 version = "1.6";
22
23 outputs = [ "out" ] ++ lib.optionals withDocs [ "man" ];
24
25 src = fetchFromGitHub {
26 owner = "linux-nvme";
27 repo = "libnvme";
28 rev = "v${finalAttrs.version}";
29 hash = "sha256-7bvjsmt16/6RycSDKIECtJ4ES7NTaspU6IMpUw0sViA=";
30 };
31
32 patches = [
33 # included in next release
34 (fetchpatch {
35 url = "https://github.com/linux-nvme/libnvme/commit/ff742e792725c316ba6de0800188bf36751bd1d1.patch";
36 hash = "sha256-IUjPUBmGQC4oAKFFlBrjonqD2YdyNPC9siK4t/t2slE=";
37 })
38 ];
39
40 postPatch = ''
41 patchShebangs scripts
42 '';
43
44 nativeBuildInputs = [
45 meson
46 ninja
47 perl # for kernel-doc
48 pkg-config
49 python3.pythonOnBuildForHost
50 swig
51 ];
52
53 buildInputs = [
54 keyutils
55 json_c
56 openssl
57 systemd
58 python3
59 ];
60
61 mesonFlags = [
62 "-Ddocs=man"
63 (lib.mesonBool "tests" finalAttrs.doCheck)
64 (lib.mesonBool "docs-build" withDocs)
65 ];
66
67 preConfigure = ''
68 export KBUILD_BUILD_TIMESTAMP="$(date -u -d @$SOURCE_DATE_EPOCH)"
69 '';
70
71 # mocked ioctl conflicts with the musl one: https://github.com/NixOS/nixpkgs/pull/263768#issuecomment-1782877974
72 doCheck = !stdenv.hostPlatform.isMusl;
73
74 meta = with lib; {
75 description = "C Library for NVM Express on Linux";
76 homepage = "https://github.com/linux-nvme/libnvme";
77 maintainers = with maintainers; [ fogti vifino ];
78 license = with licenses; [ lgpl21Plus ];
79 platforms = platforms.linux;
80 };
81})