diff --git a/pkgs/cloud-hypervisor-gpu.nix b/pkgs/cloud-hypervisor-gpu.nix index 27cc554..a99ce6f 100644 --- a/pkgs/cloud-hypervisor-gpu.nix +++ b/pkgs/cloud-hypervisor-gpu.nix @@ -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