From 61e396f19da1e7ea4d5b2e01f8d7e628e18c05f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 24 Jan 2025 15:12:28 +0100 Subject: [PATCH] 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 --- pkgs/applications/virtualization/qemu/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 9aa0c637d2b6..5853f258c4f0 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -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"