qemu-utils: enable crypto support

This is required for qemu-img to support luks.
This was discovered when trying to fix a failing build with
python3Packages.oslo-utils on at least version 7.4.0.

Both (lib)gcrypt and nettle together with hogweed are fallbacks when
gnutls is not found and are not used despite the convoluted build script
suggesting it.

Configure output before this patch:

...
  Crypto
    TLS priority                    : NORMAL
    GNUTLS support                  : YES 3.8.6
      GNUTLS crypto                 : YES
    libgcrypt                       : NO
    nettle                          : NO
    SM4 ALG support                 : NO
    SM3 ALG support                 : NO
    AF_ALG support                  : NO
    rng-none                        : NO
    Linux keyring                   : YES
    Linux keyutils                  : NO
...

and after this patch:

...
  Crypto
    TLS priority                    : NORMAL
    GNUTLS support                  : YES 3.8.6
      GNUTLS crypto                 : YES
    libgcrypt                       : NO
    nettle                          : NO
    SM4 ALG support                 : NO
    SM3 ALG support                 : NO
    AF_ALG support                  : NO
    rng-none                        : NO
    Linux keyring                   : YES
    Linux keyutils                  : NO
...

This can be easily tested by building qemu-utils and running

qemu-img create -f luks --object secret,id=sec0,data=secret-passphrase -o key-secret=sec0 tmp.img 536870912

which is the command that failed in oslo-utils
This commit is contained in:
Sandro Jäckel
2025-01-25 16:53:50 +01:00
parent d1dac6d20e
commit 61e396f19d
@@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, fetchpatch, python3Packages, zlib, pkg-config, glib, overrideSDK, buildPackages
, pixman, vde2, alsa-lib, flex, pcre2
, bison, lzo, snappy, libaio, libtasn1, gnutls, nettle, curl, dtc, ninja, meson, perl
, bison, lzo, snappy, libaio, libtasn1, gnutls, curl, dtc, ninja, meson, perl
, sigtool
, makeWrapper, removeReferencesTo
, attr, libcap, libcap_ng, socat, libslirp
@@ -94,8 +94,9 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals stdenv.hostPlatform.isDarwin [ sigtool rez setfile ]
++ lib.optionals (!userOnly) [ dtc ];
buildInputs = [ glib zlib ]
++ lib.optionals (!minimal) [ dtc pixman vde2 lzo snappy libtasn1 gnutls nettle libslirp ]
# gnutls is required for crypto support (luks) in qemu-img
buildInputs = [ glib gnutls zlib ]
++ lib.optionals (!minimal) [ dtc pixman vde2 lzo snappy libtasn1 libslirp ]
++ lib.optionals (!userOnly) [ curl ]
++ lib.optionals ncursesSupport [ ncurses ]
++ lib.optionals stdenv.hostPlatform.isDarwin darwinSDK
@@ -166,6 +167,7 @@ stdenv.mkDerivation (finalAttrs: {
configureFlags = [
"--disable-strip" # We'll strip ourselves after separating debug info.
"--enable-gnutls" # auto detection only works when building with --enable-system
(lib.enableFeature enableDocs "docs")
(lib.enableFeature enableTools "tools")
"--localstatedir=/var"