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
|
let
|
||||||
|
inherit (lib) optionals 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";
|
||||||
|
|
@ -15,37 +16,60 @@ let
|
||||||
in
|
in
|
||||||
cloud-hypervisor.overrideAttrs (
|
cloud-hypervisor.overrideAttrs (
|
||||||
finalAttrs: oldAttrs:
|
finalAttrs: oldAttrs:
|
||||||
{
|
let
|
||||||
# Verbatim from spectrum
|
patchesFromDir =
|
||||||
postUnpack = oldAttrs.postUnpack or "" + ''
|
root:
|
||||||
unpackFile $vhost
|
builtins.concatMap (name: lib.optionals (lib.hasSuffix ".patch" name) [ (root + "/${name}") ]) (
|
||||||
chmod -R +w vhost
|
builtins.attrNames (builtins.readDir root)
|
||||||
'';
|
);
|
||||||
vhost = fetchFromGitHub {
|
spectrumPatches = {
|
||||||
name = "vhost";
|
version = "2025-12-20";
|
||||||
owner = "rust-vmm";
|
vhost = fetchFromGitHub {
|
||||||
repo = "vhost";
|
name = "vhost";
|
||||||
rev = "vhost-user-backend-v0.20.0";
|
owner = "rust-vmm";
|
||||||
hash = "sha256-KK1+mwYQr7YkyGT9+51v7TJael9D0lle2JXfRoTqYq8=";
|
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 [ ] ++ [
|
patches =
|
||||||
"${spectrum}/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch"
|
removeAll oldPatches (oldAttrs.patches or [ ]) ++ optionals overridePatches spectrumPatches.patches;
|
||||||
"${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"));
|
|
||||||
# Verbatim copy from spectrum
|
# Verbatim copy from spectrum
|
||||||
postPatch = oldAttrs.postPatch or "" + ''
|
postPatch =
|
||||||
pushd ../vhost
|
oldAttrs.postPatch or ""
|
||||||
for patch in $vhostPatches; do
|
+ optionalString (!previouslyPatched) ''
|
||||||
echo applying patch $patch
|
pushd ../vhost
|
||||||
patch -p1 < $patch
|
for patch in $vhostPatches; do
|
||||||
done
|
echo applying patch $patch
|
||||||
popd
|
patch -p1 < $patch
|
||||||
'';
|
done
|
||||||
|
popd
|
||||||
|
'';
|
||||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||||
inherit (finalAttrs) patches;
|
inherit (finalAttrs) patches;
|
||||||
inherit (oldAttrs) src;
|
inherit (oldAttrs) src;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue