muvm: init from krun as 0.4.1; libkrunfw: 4.5.1 -> 4.9.0; libkrun: 1.9.8 -> 1.11.2 (#397932)

This commit is contained in:
Tristan Ross
2025-05-02 21:02:18 -07:00
committed by GitHub
5 changed files with 134 additions and 79 deletions
-70
View File
@@ -1,70 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
rustPlatform,
libkrun,
makeWrapper,
passt,
sommelier,
mesa,
withSommelier ? false,
}:
rustPlatform.buildRustPackage {
pname = "krun";
version = "0-unstable-2024-06-18";
src = fetchFromGitHub {
owner = "slp";
repo = "krun";
rev = "912afa5c6525b7c8f83dffd65ec4b1425b3f7521";
hash = "sha256-rDuxv3UakAemDnj4Nsbpqsykts2IcseuQmDwO24L+u8=";
};
patches = [
(fetchpatch {
url = "https://github.com/slp/krun/pull/39.diff";
hash = "sha256-CV69L+VDDLRcWgpgDCAYKLlTU9ytFcHhzNgOibWD8KY=";
})
(fetchpatch {
url = "https://github.com/slp/krun/pull/38.diff";
hash = "sha256-cK3iDhh+33H16V65lWUXahjmpSxI1HhiLUmkjfkRB7A=";
})
];
useFetchCargoVendor = true;
cargoHash = "sha256-5zrwxyzt9ZEdUNUMnCaFUVpaO53RAabVdtib9LG6Q1s=";
nativeBuildInputs = [
rustPlatform.bindgenHook
makeWrapper
];
buildInputs = [
(libkrun.override {
withGpu = true;
withNet = true;
})
];
# Allow for sommelier to be disabled as it can cause problems.
wrapArgs = [
"--prefix PATH : ${lib.makeBinPath (lib.optional withSommelier [ sommelier ] ++ [ passt ])}"
];
postFixup = ''
wrapProgram $out/bin/krun $wrapArgs \
--set-default OPENGL_DRIVER ${mesa.driverLink}
'';
meta = {
description = "Run programs from your system in a microVM";
homepage = "https://github.com/slp/krun";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ RossComputerGuy ];
platforms = libkrun.meta.platforms;
mainProgram = "krun";
};
}
+18 -5
View File
@@ -13,6 +13,7 @@
virglrenderer,
libkrunfw,
rustc,
withBlk ? false,
withGpu ? false,
withSound ? false,
withNet ? false,
@@ -21,13 +22,13 @@
stdenv.mkDerivation (finalAttrs: {
pname = "libkrun";
version = "1.9.8";
version = "1.11.2";
src = fetchFromGitHub {
owner = "containers";
repo = "libkrun";
tag = "v${finalAttrs.version}";
hash = "sha256-a5ot5ad8boANK3achn6PJ52k/xmxawbTM0/hEEC/fss=";
hash = "sha256-B11f7uG/oODwkME2rauCFbVysxUtUrUmd6RKeuBdnUU=";
};
outputs = [
@@ -37,9 +38,19 @@ stdenv.mkDerivation (finalAttrs: {
cargoDeps = rustPlatform.fetchCargoVendor {
inherit (finalAttrs) src;
hash = "sha256-X1NPZQaXFBw9IKD2DbBCPug0WDjv8XnpefbA2RNJgFU=";
hash = "sha256-bcHy8AfO9nzSZKoFlEpPKvwupt3eMb+A2rHDaUzO3/U=";
};
# Make sure libkrunfw can be found by dlopen()
# FIXME: This wasn't needed previously. What changed?
env.RUSTFLAGS = toString (
map (flag: "-C link-arg=" + flag) [
"-Wl,--push-state,--no-as-needed"
"-lkrunfw"
"-Wl,--pop-state"
]
);
nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustPlatform.bindgenHook
@@ -65,6 +76,7 @@ stdenv.mkDerivation (finalAttrs: {
[
"PREFIX=${placeholder "out"}"
]
++ lib.optional withBlk "BLK=1"
++ lib.optional withGpu "GPU=1"
++ lib.optional withSound "SND=1"
++ lib.optional withNet "NET=1"
@@ -72,8 +84,8 @@ stdenv.mkDerivation (finalAttrs: {
postInstall = ''
mkdir -p $dev/lib/pkgconfig
mv $out/lib64/pkgconfig $dev/lib/pkgconfig
mv $out/include $dev/include
mv $out/lib64/pkgconfig $dev/lib/
mv $out/include $dev/
'';
meta = with lib; {
@@ -83,6 +95,7 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with maintainers; [
nickcao
RossComputerGuy
nrabulinski
];
platforms = libkrunfw.meta.platforms;
};
+5 -4
View File
@@ -15,18 +15,18 @@
stdenv.mkDerivation (finalAttrs: {
pname = "libkrunfw";
version = "4.5.1";
version = "4.9.0";
src = fetchFromGitHub {
owner = "containers";
repo = "libkrunfw";
tag = "v${finalAttrs.version}";
hash = "sha256-GFfBiGMOyBwMKjpD1kj3vRpvjR0ydji3QNDyoOQoQsw=";
hash = "sha256-wmvjex68Mh7qehA33WNBYHhV9Q/XWLixokuGWnqJ3n0=";
};
kernelSrc = fetchurl {
url = "mirror://kernel/linux/kernel/v6.x/linux-6.6.59.tar.xz";
hash = "sha256-I2FoCNjAjxKBX/iY9O20wROXorKEPQKe5iRS0hgzp20=";
url = "mirror://kernel/linux/kernel/v6.x/linux-6.12.20.tar.xz";
hash = "sha256-Iw6JsHsKuC508H7MG+4xBdyoHQ70qX+QCSnEBySbasc=";
};
postPatch = ''
@@ -71,6 +71,7 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with maintainers; [
nickcao
RossComputerGuy
nrabulinski
];
platforms = [ "x86_64-linux" ] ++ lib.optionals (!sevVariant) [ "aarch64-linux" ];
};
+110
View File
@@ -0,0 +1,110 @@
{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
libkrun,
passt,
dhcpcd,
systemd,
udev,
pkg-config,
procps,
fex,
writeShellApplication,
coreutils,
makeBinaryWrapper,
# TODO: Enable again when sommelier is not broken.
# For now, don't give false impression of sommelier being supported.
# sommelier,
# withSommelier ? false,
}:
let
# TODO: Setup setuid wrappers.
# E.g. FEX needs fusermount for rootfs functionality
initScript = writeShellApplication {
name = "muvm-init";
runtimeInputs = [
coreutils
];
text = ''
if [[ ! -f /etc/NIXOS ]]; then exit; fi
ln -s /run/muvm-host/run/current-system /run/current-system
# Only create the symlink if that path exists on the host and is a directory.
if [[ -d /run/muvm-host/run/opengl-driver ]]; then ln -s /run/muvm-host/run/opengl-driver /run/opengl-driver; fi
'';
};
binPath = [
dhcpcd
passt
(placeholder "out")
] ++ lib.optionals stdenv.isAarch64 [ fex ];
wrapArgs = lib.escapeShellArgs [
"--prefix"
"PATH"
":"
(lib.makeBinPath binPath)
"--add-flags"
"--execute-pre=${lib.getExe initScript}"
];
in
rustPlatform.buildRustPackage rec {
pname = "muvm";
version = "0.4.1";
src = fetchFromGitHub {
owner = "AsahiLinux";
repo = pname;
rev = "muvm-${version}";
hash = "sha256-1XPhVEj7iqTxdWyYwNk6cbb9VRGuhpvvowYDPJb1cWU=";
};
useFetchCargoVendor = true;
cargoHash = "sha256-fkvdS0c1Ib8Kto44ou06leXy731cpMHXevyFR5RROt4=";
postPatch =
''
substituteInPlace crates/muvm/src/guest/bin/muvm-guest.rs \
--replace-fail "/usr/lib/systemd/systemd-udevd" "${systemd}/lib/systemd/systemd-udevd"
substituteInPlace crates/muvm/src/monitor.rs \
--replace-fail "/sbin/sysctl" "${lib.getExe' procps "sysctl"}"
''
# Only patch FEX path if we're aarch64, otherwise we don't want the derivation to pull in FEX in any way
+ lib.optionalString stdenv.isAarch64 ''
substituteInPlace crates/muvm/src/guest/mount.rs \
--replace-fail "/usr/share/fex-emu" "${fex}/share/fex-emu"
'';
nativeBuildInputs = [
rustPlatform.bindgenHook
makeBinaryWrapper
pkg-config
];
buildInputs = [
(libkrun.override {
withBlk = true;
withGpu = true;
withNet = true;
})
udev
];
postFixup = ''
wrapProgram $out/bin/muvm ${wrapArgs}
'';
meta = {
description = "Run programs from your system in a microVM";
homepage = "https://github.com/AsahiLinux/muvm";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
RossComputerGuy
nrabulinski
];
inherit (libkrun.meta) platforms;
mainProgram = "muvm";
};
}
+1
View File
@@ -917,6 +917,7 @@ mapAliases {
kramdown-rfc2629 = throw "'kramdown-rfc2629' has been renamed to/replaced by 'rubyPackages.kramdown-rfc2629'"; # Converted to throw 2024-10-17
krb5Full = krb5;
krita-beta = throw "'krita-beta' has been renamed to/replaced by 'krita'"; # Converted to throw 2024-10-17
krun = throw "'krun' has been renamed to/replaced by 'muvm'"; # Added 2025-05-01
kubei = kubeclarity; # Added 2023-05-20
kubo-migrator-all-fs-repo-migrations = kubo-fs-repo-migrations; # Added 2024-09-24