fixup! cloud-hypervisor-gpu: make it easier to ignore patches from other ovrlays

This commit is contained in:
Else Someone 2026-02-27 19:38:26 +02:00
parent b84ef62e8f
commit dd6609ba3f

View file

@ -7,7 +7,7 @@
}:
let
inherit (lib) optionals optionalString;
inherit (lib) optionals optionalAttrs optionalString;
spectrum = builtins.fetchTree {
url = "https://spectrum-os.org/git/spectrum";
type = "git";
@ -36,18 +36,14 @@ cloud-hypervisor.overrideAttrs (
};
previouslyPatched = oldAttrs ? spectrumPatches;
patchPhases = !previouslyPatched;
overridePatches =
lib.versionOlder oldAttrs.spectrumPatches.version or "2000-00-00"
spectrumPatches.version;
isNewer = lib.versionOlder oldAttrs.spectrumPatches.version or "2000-00-00" spectrumPatches.version;
oldPatches = oldAttrs.spectrumPatches.patches or [ ];
removeAll = removeElts: lst: builtins.filter (x: !(builtins.elem x removeElts)) lst;
in
{
passthru =
oldAttrs.passthru or { }
// lib.optionalAttrs overridePatches {
inherit spectrumPatches;
};
optionalAttrs isNewer {
passthru = oldAttrs.passthru or { } // {
inherit spectrumPatches;
};
# Verbatim from spectrum
postUnpack =
oldAttrs.postUnpack or ""
@ -55,14 +51,14 @@ cloud-hypervisor.overrideAttrs (
unpackFile $vhost
chmod -R +w vhost
'';
vhost = if overridePatches then spectrumPatches.vhost else oldAttrs.vhost or null;
inherit (spectrumPatches) vhost;
patches =
removeAll oldPatches (oldAttrs.patches or [ ]) ++ optionals overridePatches spectrumPatches.patches;
patches = removeAll oldPatches (oldAttrs.patches or [ ]) ++ spectrumPatches.patches;
inherit (spectrumPatches) vhostPatches;
# Verbatim copy from spectrum
postPatch =
oldAttrs.postPatch or ""
+ optionalString (!previouslyPatched) ''
+ optionalString patchPhases ''
pushd ../vhost
for patch in $vhostPatches; do
echo applying patch $patch