1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
{ stdenv, config, lib, fetchFromGitHub
, cmake
, pkgconfig
, gettext
, libpthreadstubs
, libudev
, libusb1
, ncurses
, qemu
, sqlite
, libxml2 ? null
, libarchive ? null
, graphviz ? null
, dbus ? null
, debugBuild ? false
, ovfSupport ? true
, saveVMSupport ? false # requires patched version of QEMU, override them all if needed
, withVNCClientSupport ? true
, withSpice ? true
, withNetworkMap ? false
, withDbus ? false
}:
assert ovfSupport -> libxml2 != null;
assert ovfSupport -> libarchive != null;
assert withNetworkMap -> graphviz != null;
assert withDbus -> dbus != null;
stdenv.mkDerivation rec {
pname = "nemu";
version = "2020-03-11";
src = fetchFromGitHub {
owner = "nemuTUI";
repo = pname;
rev = "a3f179abd62ed23ccb8de2f79820aee2791767cf";
sha256 = "0rib0s161x8ca1dxqjf9qwq6l96q02m04dai7ls6dbgzm2vvfcwd";
};
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isEnabled "VETH")
(isEnabled "MACVTAP")
];
nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [
gettext
libarchive
libpthreadstubs
libudev
libusb1
libxml2
ncurses
qemu
sqlite
]
++ (lib.optional withNetworkMap graphviz)
++ (lib.optional withDbus dbus);
cmakeFlags = []
++ (lib.optional debugBuild "-DNM_DEBUG=ON")
++ (lib.optional ovfSupport "-DNM_WITH_OVF_SUPPORT=ON")
++ (lib.optional saveVMSupport "-DNM_SAVEVM_SNAPSHOTS=ON")
++ (lib.optional withVNCClientSupport "-DNM_WITH_VNC_CLIENT=ON")
++ (lib.optional withSpice "-DNM_WITH_SPICE=ON")
++ (lib.optional withNetworkMap "-DNM_WITH_NETWORK_MAP=ON")
++ (lib.optional withDbus "-DNM_WITH_DBUS=ON")
;
preConfigure = ''
patchShebangs .
substituteInPlace CMakeLists.txt --replace 'USR_PREFIX "/usr"' "USR_PREFIX \"$(out)\""
substituteInPlace src/nm_cfg_file.c --replace /bin/false /run/current-system/sw/bin/false
substituteInPlace src/nm_cfg_file.c --replace /share/nemu/templates/config/nemu.cfg.sample \
$out/share/nemu/templates/config/nemu.cfg.sample
substituteInPlace src/nm_cfg_file.c --replace \
' nm_str_format(&qemu_bin, "%s/bin/qemu-system-%s",
NM_STRING(NM_USR_PREFIX), token);' \
' nm_str_format(&qemu_bin, "/run/wrappers/bin/qemu-system-%s", token);'
substituteInPlace src/nm_cfg_file.c --replace "/usr/bin" /run/current-system/sw/bin
substituteInPlace src/nm_add_vm.c --replace /bin/qemu-img ${qemu}/bin/qemu-img # 2.2.1 only
substituteInPlace src/nm_machine.c --replace \
' nm_str_format(&buf, "%s/bin/qemu-system-%s",
NM_STRING(NM_USR_PREFIX), arch);' \
' nm_str_format(&buf, "/run/wrappers/bin/qemu-system-%s", arch);'
substituteInPlace src/nm_add_drive.c --replace /bin/qemu-img ${qemu}/bin/qemu-img
substituteInPlace src/nm_ovf_import.c --replace /bin/qemu-img ${qemu}/bin/qemu-img
substituteInPlace src/nm_vm_snapshot.c --replace /bin/qemu-img ${qemu}/bin/qemu-img
substituteInPlace src/nm_vm_control.c --replace /bin/qemu-system- ${qemu}/bin/qemu-system-
substituteInPlace nemu.cfg.sample --replace /usr/bin /run/current-system/sw/bin
substituteInPlace lang/ru/nemu.po --replace /bin/false /run/current-system/sw/bin/false
substituteInPlace sh/ntty --replace /usr/bin /run/current-system/sw/bin
#mkdir -p $out/share/bash-completion/completions
'';
preInstall = ''
install -D -m0644 -t $out/share/doc ../LICENSE
'';
meta = {
homepage = "https://github.com/nemuTUI/nemu";
description = "Ncurses UI for QEMU";
license = stdenv.lib.licenses.bsd2;
maintainers = [ stdenv.lib.maintainers.matthiasbeyer ];
platforms = with stdenv.lib.platforms; linux;
};
}
|