cloud-hypervisor-gpu: make it easier to ignore patches from other ovrlays
This commit is contained in:
parent
384b45bdef
commit
b84ef62e8f
1 changed files with 52 additions and 28 deletions
|
|
@ -7,6 +7,7 @@
|
|||
}:
|
||||
|
||||
let
|
||||
inherit (lib) optionals optionalString;
|
||||
spectrum = builtins.fetchTree {
|
||||
url = "https://spectrum-os.org/git/spectrum";
|
||||
type = "git";
|
||||
|
|
@ -15,37 +16,60 @@ let
|
|||
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=";
|
||||
let
|
||||
patchesFromDir =
|
||||
root:
|
||||
builtins.concatMap (name: lib.optionals (lib.hasSuffix ".patch" name) [ (root + "/${name}") ]) (
|
||||
builtins.attrNames (builtins.readDir root)
|
||||
);
|
||||
spectrumPatches = {
|
||||
version = "2025-12-20";
|
||||
vhost = fetchFromGitHub {
|
||||
name = "vhost";
|
||||
owner = "rust-vmm";
|
||||
repo = "vhost";
|
||||
rev = "vhost-user-backend-v0.20.0";
|
||||
hash = "sha256-KK1+mwYQr7YkyGT9+51v7TJael9D0lle2JXfRoTqYq8=";
|
||||
};
|
||||
patches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor");
|
||||
vhostPatches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor/vhost");
|
||||
};
|
||||
previouslyPatched = oldAttrs ? spectrumPatches;
|
||||
patchPhases = !previouslyPatched;
|
||||
overridePatches =
|
||||
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;
|
||||
};
|
||||
# Verbatim from spectrum
|
||||
postUnpack =
|
||||
oldAttrs.postUnpack or ""
|
||||
+ optionalString patchPhases ''
|
||||
unpackFile $vhost
|
||||
chmod -R +w vhost
|
||||
'';
|
||||
vhost = if overridePatches then spectrumPatches.vhost else oldAttrs.vhost or null;
|
||||
|
||||
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"));
|
||||
patches =
|
||||
removeAll oldPatches (oldAttrs.patches or [ ]) ++ optionals overridePatches spectrumPatches.patches;
|
||||
# Verbatim copy from spectrum
|
||||
postPatch = oldAttrs.postPatch or "" + ''
|
||||
pushd ../vhost
|
||||
for patch in $vhostPatches; do
|
||||
echo applying patch $patch
|
||||
patch -p1 < $patch
|
||||
done
|
||||
popd
|
||||
'';
|
||||
postPatch =
|
||||
oldAttrs.postPatch or ""
|
||||
+ optionalString (!previouslyPatched) ''
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue