nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 pkg-config,
7 glib,
8 which,
9 bison,
10 nixosTests,
11 libnl,
12 linuxHeaders,
13 gnutls,
14}:
15
16stdenv.mkDerivation rec {
17 pname = "nbd";
18 version = "3.25";
19
20 src = fetchurl {
21 url = "https://github.com/NetworkBlockDevice/nbd/releases/download/nbd-${version}/nbd-${version}.tar.xz";
22 hash = "sha256-9cj9D8tXsckmWU0OV/NWQy7ghni+8dQNCI8IMPDL3Qo=";
23 };
24
25 patches = [
26 # fix port setting from nbdtab
27 # https://github.com/NetworkBlockDevice/nbd/pull/154
28 (fetchpatch {
29 url = "https://github.com/NetworkBlockDevice/nbd/commit/915444bc0b8a931d32dfb755542f4bd1d37f1449.patch";
30 hash = "sha256-6z+c2cXhY92WPDqRO6AJ5BBf1N38yTgOE1foduIr5Dg=";
31 })
32 ];
33
34 nativeBuildInputs = [
35 pkg-config
36 which
37 bison
38 ];
39
40 buildInputs = [
41 glib
42 gnutls
43 ]
44 ++ lib.optionals stdenv.hostPlatform.isLinux [
45 libnl
46 linuxHeaders
47 ];
48
49 configureFlags = [
50 "--sysconfdir=/etc"
51 ];
52
53 # ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
54 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=implicit-function-declaration";
55
56 doCheck = !stdenv.hostPlatform.isDarwin;
57
58 passthru.tests = {
59 test = nixosTests.nbd;
60 };
61
62 meta = {
63 homepage = "https://nbd.sourceforge.io/";
64 description = "Map arbitrary files as block devices over the network";
65 license = lib.licenses.gpl2Only;
66 platforms = lib.platforms.unix;
67 maintainers = with lib.maintainers; [ nickcao ];
68 };
69}