cloud-hypervisor: clean up the short-circuiting logic

This commit is contained in:
Else Someone 2026-03-22 21:25:48 +02:00
parent 42180096af
commit 8fb586c8b6

View file

@ -34,10 +34,10 @@ cloud-hypervisor.overrideAttrs (
patches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor");
vhostPatches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor/vhost");
};
previouslyPatched = oldAttrs ? spectrumPatches;
patchPhases = !previouslyPatched;
oldPatchesStruct = oldAttrs.passthru.spectrumPatches or { };
missingPatchPhases = previouslyPatched != { };
isNewer = lib.versionOlder oldAttrs.spectrumPatches.version or "2000-00-00" spectrumPatches.version;
oldPatches = oldAttrs.spectrumPatches.patches or [ ];
oldPatches = oldPatchesStruct.patches or [ ];
removeAll = removeElts: lst: builtins.filter (x: !(builtins.elem x removeElts)) lst;
in
optionalAttrs isNewer {
@ -47,7 +47,7 @@ cloud-hypervisor.overrideAttrs (
# Verbatim from spectrum
postUnpack =
oldAttrs.postUnpack or ""
+ optionalString patchPhases ''
+ optionalString missingPatchPhases ''
unpackFile $vhost
chmod -R +w vhost
'';
@ -58,7 +58,7 @@ cloud-hypervisor.overrideAttrs (
# Verbatim copy from spectrum
postPatch =
oldAttrs.postPatch or ""
+ optionalString patchPhases ''
+ optionalString missingPatchPhases ''
pushd ../vhost
for patch in $vhostPatches; do
echo applying patch $patch