Merge pull request #262579 from hercules-ci/qemu-utils-build-closure-size

`qemu-utils`: reduce build closure size

authored by Robert Hensing and committed by GitHub 723cfc50 87391b68

+37 -47
+34 -22
pkgs/applications/virtualization/qemu/default.nix
··· 4 4 , makeWrapper, removeReferencesTo 5 5 , attr, libcap, libcap_ng, socat, libslirp 6 6 , CoreServices, Cocoa, Hypervisor, rez, setfile, vmnet 7 - , guestAgentSupport ? with stdenv.hostPlatform; isLinux || isNetBSD || isOpenBSD || isSunOS || isWindows 8 - , numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl 9 - , seccompSupport ? stdenv.isLinux, libseccomp 10 - , alsaSupport ? lib.hasSuffix "linux" stdenv.hostPlatform.system && !nixosTestRunner 11 - , pulseSupport ? !stdenv.isDarwin && !nixosTestRunner, libpulseaudio 12 - , pipewireSupport ? !stdenv.isDarwin && !nixosTestRunner, pipewire 13 - , sdlSupport ? !stdenv.isDarwin && !nixosTestRunner, SDL2, SDL2_image 14 - , jackSupport ? !stdenv.isDarwin && !nixosTestRunner, libjack2 15 - , gtkSupport ? !stdenv.isDarwin && !xenSupport && !nixosTestRunner, gtk3, gettext, vte, wrapGAppsHook 16 - , vncSupport ? !nixosTestRunner, libjpeg, libpng 17 - , smartcardSupport ? !nixosTestRunner, libcacard 18 - , spiceSupport ? true && !nixosTestRunner, spice, spice-protocol 19 - , ncursesSupport ? !nixosTestRunner, ncurses 7 + , guestAgentSupport ? (with stdenv.hostPlatform; isLinux || isNetBSD || isOpenBSD || isSunOS || isWindows) && !toolsOnly 8 + , numaSupport ? stdenv.isLinux && !stdenv.isAarch32 && !toolsOnly, numactl 9 + , seccompSupport ? stdenv.isLinux && !toolsOnly, libseccomp 10 + , alsaSupport ? lib.hasSuffix "linux" stdenv.hostPlatform.system && !nixosTestRunner && !toolsOnly 11 + , pulseSupport ? !stdenv.isDarwin && !nixosTestRunner && !toolsOnly, libpulseaudio 12 + , pipewireSupport ? !stdenv.isDarwin && !nixosTestRunner && !toolsOnly, pipewire 13 + , sdlSupport ? !stdenv.isDarwin && !nixosTestRunner && !toolsOnly, SDL2, SDL2_image 14 + , jackSupport ? !stdenv.isDarwin && !nixosTestRunner && !toolsOnly, libjack2 15 + , gtkSupport ? !stdenv.isDarwin && !xenSupport && !nixosTestRunner && !toolsOnly, gtk3, gettext, vte, wrapGAppsHook 16 + , vncSupport ? !nixosTestRunner && !toolsOnly, libjpeg, libpng 17 + , smartcardSupport ? !nixosTestRunner && !toolsOnly, libcacard 18 + , spiceSupport ? true && !nixosTestRunner && !toolsOnly, spice, spice-protocol 19 + , ncursesSupport ? !nixosTestRunner && !toolsOnly, ncurses 20 20 , usbredirSupport ? spiceSupport, usbredir 21 21 , xenSupport ? false, xen 22 22 , cephSupport ? false, ceph 23 23 , glusterfsSupport ? false, glusterfs, libuuid 24 24 , openGLSupport ? sdlSupport, mesa, libepoxy, libdrm 25 25 , virglSupport ? openGLSupport, virglrenderer 26 - , libiscsiSupport ? true, libiscsi 26 + , libiscsiSupport ? !toolsOnly, libiscsi 27 27 , smbdSupport ? false, samba 28 - , tpmSupport ? true 28 + , tpmSupport ? !toolsOnly 29 29 , uringSupport ? stdenv.isLinux, liburing 30 30 , canokeySupport ? false, canokey-qemu 31 - , capstoneSupport ? true, capstone 31 + , capstoneSupport ? !toolsOnly, capstone 32 32 , enableDocs ? true 33 33 , hostCpuOnly ? false 34 - , hostCpuTargets ? (if hostCpuOnly 34 + , hostCpuTargets ? (if toolsOnly 35 + then [ ] 36 + else if hostCpuOnly 35 37 then (lib.optional stdenv.isx86_64 "i386-softmmu" 36 38 ++ ["${stdenv.hostPlatform.qemuArch}-softmmu"]) 37 39 else null) 38 40 , nixosTestRunner ? false 41 + , toolsOnly ? false 39 42 , gitUpdater 43 + , qemu-utils # for tests attribute 40 44 }: 41 45 42 46 let ··· 47 51 pname = "qemu" 48 52 + lib.optionalString xenSupport "-xen" 49 53 + lib.optionalString hostCpuOnly "-host-cpu-only" 50 - + lib.optionalString nixosTestRunner "-for-vm-tests"; 54 + + lib.optionalString nixosTestRunner "-for-vm-tests" 55 + + lib.optionalString toolsOnly "-utils"; 51 56 version = "8.1.2"; 52 57 53 58 src = fetchurl { ··· 239 244 ''; 240 245 241 246 # Add a ‘qemu-kvm’ wrapper for compatibility/convenience. 242 - postInstall = '' 247 + postInstall = lib.optionalString (!toolsOnly) '' 243 248 ln -s $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm 244 249 ''; 245 250 246 251 passthru = { 247 252 qemu-system-i386 = "bin/qemu-system-i386"; 248 - tests = { 253 + tests = lib.optionalAttrs (!toolsOnly) { 249 254 qemu-tests = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; }); 255 + qemu-utils-builds = qemu-utils; 250 256 }; 251 257 updateScript = gitUpdater { 252 258 # No nicer place to find latest release. ··· 261 267 262 268 meta = with lib; { 263 269 homepage = "http://www.qemu.org/"; 264 - description = "A generic and open source machine emulator and virtualizer"; 270 + description = 271 + if toolsOnly 272 + then "Support tools for qemu, a machine emulator and virtualizer" 273 + else "A generic and open source machine emulator and virtualizer"; 265 274 license = licenses.gpl2Plus; 266 - mainProgram = "qemu-kvm"; 267 275 maintainers = with maintainers; [ eelco qyliss ]; 268 276 platforms = platforms.unix; 277 + } 278 + # toolsOnly: Does not have qemu-kvm and there's no main support tool 279 + // lib.optionalAttrs (!toolsOnly) { 280 + mainProgram = "qemu-kvm"; 269 281 }; 270 282 })
-24
pkgs/applications/virtualization/qemu/utils.nix
··· 1 - { stdenv, installShellFiles, qemu_kvm, removeReferencesTo }: 2 - 3 - stdenv.mkDerivation rec { 4 - pname = "qemu-utils"; 5 - inherit (qemu_kvm) version; 6 - 7 - nativeBuildInputs = [ installShellFiles ]; 8 - buildInputs = [ qemu_kvm ]; 9 - disallowedRequisites = [ qemu_kvm ]; 10 - unpackPhase = "true"; 11 - 12 - installPhase = '' 13 - mkdir -p "$out/bin" 14 - cp "${qemu_kvm}/bin/qemu-img" "$out/bin/qemu-img" 15 - cp "${qemu_kvm}/bin/qemu-io" "$out/bin/qemu-io" 16 - cp "${qemu_kvm}/bin/qemu-nbd" "$out/bin/qemu-nbd" 17 - ${removeReferencesTo}/bin/remove-references-to -t ${qemu_kvm} $out/bin/* 18 - 19 - installManPage ${qemu_kvm}/share/man/man1/qemu-img.1.gz 20 - installManPage ${qemu_kvm}/share/man/man8/qemu-nbd.8.gz 21 - ''; 22 - 23 - inherit (qemu_kvm) meta; 24 - }
+3 -1
pkgs/top-level/all-packages.nix
··· 34868 34868 inherit (darwin) sigtool; 34869 34869 }; 34870 34870 34871 - qemu-utils = callPackage ../applications/virtualization/qemu/utils.nix { }; 34871 + qemu-utils = qemu.override { 34872 + toolsOnly = true; 34873 + }; 34872 34874 34873 34875 canokey-qemu = callPackage ../applications/virtualization/qemu/canokey-qemu.nix { }; 34874 34876