diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-11-30 18:54:47 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-11-30 18:54:47 +0000 |
commit | 01bce76b116a786c883ec309e05d2e2d1b6999c4 (patch) | |
tree | 3c631a1e71803fcb9a8b2506d559fc38ae773ee3 /pkgs/applications/virtualization/qemu | |
parent | b251814ec7c44f8b7d7d3fc8e4b0d79ff9cd1f40 (diff) | |
parent | 3c6eb8fe497b4a094c76fa05ead39234e7522f1e (diff) |
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts: pkgs/applications/virtualization/qemu/default.nix
Diffstat (limited to 'pkgs/applications/virtualization/qemu')
-rw-r--r-- | pkgs/applications/virtualization/qemu/default.nix | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index e229825718cdf..875318e762ead 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, fetchurl, fetchpatch, python, zlib, pkg-config, glib , perl, pixman, vde2, alsa-lib, texinfo, flex , bison, lzo, snappy, libaio, libtasn1, gnutls, nettle, curl, ninja, meson, sigtool -, makeWrapper +, makeWrapper, runtimeShell , attr, libcap, libcap_ng , CoreServices, Cocoa, Hypervisor, rez, setfile , numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl @@ -229,10 +229,13 @@ stdenv.mkDerivation rec { # Add a ‘qemu-kvm’ wrapper for compatibility/convenience. postInstall = '' + cp -- $emitKvmWarningsPath $out/libexec/emit-kvm-warnings + chmod a+x -- $out/libexec/emit-kvm-warnings if [ -x $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} ]; then makeWrapper $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} \ $out/bin/qemu-kvm \ - --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)" + --run $out/libexec/emit-kvm-warnings \ + --add-flags "\$([ -r /dev/kvm -a -w /dev/kvm ] && echo -enable-kvm)" fi ''; @@ -243,6 +246,26 @@ stdenv.mkDerivation rec { # Builds in ~3h with 2 cores, and ~20m with a big-parallel builder. requiredSystemFeatures = [ "big-parallel" ]; + emitKvmWarnings = '' + #!${runtimeShell} + WARNCOL='\033[1;35m' + NEUTRALCOL='\033[0m' + WARNING="''${WARNCOL}warning:''${NEUTRALCOL}" + if [ ! -e /dev/kvm ]; then + echo -e "''${WARNING} KVM is not available - execution will be slow" >&2 + echo "Consider installing KVM for hardware-accelerated execution." >&2 + echo "If KVM is already installed make sure the kernel module is loaded." >&2 + elif [ ! -r /dev/kvm -o ! -w /dev/kvm ]; then + echo -e "''${WARNING} /dev/kvm is not read-/writable - execution will be slow" >&2 + echo "/dev/kvm needs to be read-/writable by the user executing QEMU." >&2 + echo "" >&2 + echo "For hardware-acceleration inside the nix build sandbox /dev/kvm" >&2 + echo "must be world-read-/writable (rw-rw-rw-)." >&2 + fi + ''; + + passAsFile = [ "emitKvmWarnings" ]; + meta = with lib; { homepage = "http://www.qemu.org/"; description = "A generic and open source machine emulator and virtualizer"; |