{ lib, cloud-hypervisor, fetchFromGitHub, rustPlatform, enableDebug ? true, }: let spectrum = builtins.fetchTree { url = "https://spectrum-os.org/git/spectrum"; type = "git"; rev = "0f3388f0191d9a03c7bf471c269a34a79f22018b"; }; in cloud-hypervisor.overrideAttrs ( finalAttrs: oldAttrs: { # Verbatim from spectrum postUnpack = oldAttrs.postUnpack or "" + '' unpackFile $vhost chmod -R +w vhost ''; vhost = fetchFromGitHub { name = "vhost"; owner = "rust-vmm"; repo = "vhost"; rev = "vhost-user-backend-v0.20.0"; hash = "sha256-KK1+mwYQr7YkyGT9+51v7TJael9D0lle2JXfRoTqYq8="; }; patches = oldAttrs.patches or [ ] ++ [ "${spectrum}/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch" "${spectrum}/pkgs/cloud-hypervisor/0002-virtio-devices-add-a-GPU-device.patch" ]; vhostPatches = builtins.concatMap ( name: lib.optionals (lib.hasSuffix ".patch" name) [ "${spectrum}/pkgs/cloud-hypervisor/vhost/${name}" ] ) (builtins.attrNames (builtins.readDir "${spectrum}/pkgs/cloud-hypervisor/vhost")); # Verbatim copy from spectrum postPatch = oldAttrs.postPatch or "" + '' pushd ../vhost for patch in $vhostPatches; do echo applying patch $patch patch -p1 < $patch done popd ''; cargoDeps = rustPlatform.fetchCargoVendor { inherit (finalAttrs) patches; inherit (oldAttrs) src; hash = "sha256-wGtsyKDg1z1QK9mJ1Q43NSjoPbm3m81p++DoD8ipIUI="; }; } // lib.optionalAttrs enableDebug { buildType = "debug"; dontStrip = true; } )