diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-03-11 14:32:25 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-02-01 15:27:58 +0100 |
commit | 220c5a75b870f622cdc931c64108a13328c94a38 (patch) | |
tree | 3df3fc2fc458194d9326002c5a84fc2df5590952 | |
parent | d9ca156aad5da5d2e7272dc660dc0b0a91c91dec (diff) |
nemu: Integrate package changes from caader
Integrate changes from
https://github.com/caadar/nemu-nix/blob/master/nemu.nix
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | pkgs/applications/misc/nemu/default.nix | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/pkgs/applications/misc/nemu/default.nix b/pkgs/applications/misc/nemu/default.nix index 6b1917142369..187610e254ac 100644 --- a/pkgs/applications/misc/nemu/default.nix +++ b/pkgs/applications/misc/nemu/default.nix @@ -1,6 +1,13 @@ -{ stdenv, lib, fetchFromGitHub -, cmake, pkgconfig, gettext -, ncurses, sqlite, libusb, udev +{ stdenv, config, lib, fetchFromGitHub +, cmake +, pkgconfig +, gettext +, libpthreadstubs +, libudev +, libusb1 +, ncurses +, qemu +, sqlite , libxml2 ? null , libarchive ? null @@ -9,7 +16,7 @@ , debugBuild ? false , ovfSupport ? true -, saveVMSupport ? false +, saveVMSupport ? false # requires patched version of QEMU, override them all if needed , withVNCClientSupport ? true , withSpice ? true , withNetworkMap ? false @@ -32,10 +39,24 @@ stdenv.mkDerivation rec { sha256 = "0rib0s161x8ca1dxqjf9qwq6l96q02m04dai7ls6dbgzm2vvfcwd"; }; - nativeBuildInputs = [ cmake pkgconfig gettext ]; + system.requiredKernelConfig = with config.lib.kernelConfig; [ + (isEnabled "VETH") + (isEnabled "MACVTAP") + ]; - buildInputs = [ ncurses sqlite libusb udev libxml2 ] - ++ (lib.optional ovfSupport libarchive) + nativeBuildInputs = [ cmake pkgconfig ]; + + buildInputs = [ + gettext + libarchive + libpthreadstubs + libudev + libusb1 + libxml2 + ncurses + qemu + sqlite + ] ++ (lib.optional withNetworkMap graphviz) ++ (lib.optional withDbus dbus); @@ -49,9 +70,40 @@ stdenv.mkDerivation rec { ++ (lib.optional withDbus "-DNM_WITH_DBUS=ON") ; - installPhase = '' - mkdir -p $out/bin/ - cp nemu $out/bin/ + 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 = { |