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