muvm: init from krun as 0.4.1
Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
This commit is contained in:
co-authored by
Tristan Ross
parent
4f4753e6d2
commit
16263fc6e9
@@ -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";
|
||||
};
|
||||
}
|
||||
@@ -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";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user