1{ fetchFromGitHub
2, bash
3, json_c
4, keyutils
5, lib
6, meson
7, ninja
8, openssl
9, perl
10, pkg-config
11, python3
12, stdenv
13, swig
14, systemd
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.9";
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-nXzYbj4BDxFii30yR+aTgqjQfyYMFiAIcV/OHI2y5Ws=";
30 };
31
32 postPatch = ''
33 patchShebangs scripts
34 substituteInPlace test/sysfs/sysfs-tree-diff.sh \
35 --replace-fail /bin/bash ${bash}/bin/bash
36 '';
37
38 nativeBuildInputs = [
39 meson
40 ninja
41 perl # for kernel-doc
42 pkg-config
43 python3.pythonOnBuildForHost
44 swig
45 ];
46
47 buildInputs = [
48 keyutils
49 json_c
50 openssl
51 systemd
52 python3
53 ];
54
55 mesonFlags = [
56 "-Ddocs=man"
57 (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck)
58 (lib.mesonBool "docs-build" withDocs)
59 ];
60
61 preConfigure = ''
62 export KBUILD_BUILD_TIMESTAMP="$(date -u -d @$SOURCE_DATE_EPOCH)"
63 '';
64
65 # mocked ioctl conflicts with the musl one: https://github.com/NixOS/nixpkgs/pull/263768#issuecomment-1782877974
66 doCheck = !stdenv.hostPlatform.isMusl;
67
68 meta = with lib; {
69 description = "C Library for NVM Express on Linux";
70 homepage = "https://github.com/linux-nvme/libnvme";
71 maintainers = with maintainers; [ vifino ];
72 license = with licenses; [ lgpl21Plus ];
73 platforms = platforms.linux;
74 };
75})