Skip to content

Commit bd49b63

Browse files
muvm: init from krun as 0.4.1; libkrunfw: 4.5.1 -> 4.9.0; libkrun: 1.9.8 -> 1.11.2 (#397932)
2 parents e818f3c + 8a30e8f commit bd49b63

5 files changed

Lines changed: 134 additions & 79 deletions

File tree

pkgs/by-name/kr/krun/package.nix

Lines changed: 0 additions & 70 deletions
This file was deleted.

pkgs/by-name/li/libkrun/package.nix

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
virglrenderer,
1414
libkrunfw,
1515
rustc,
16+
withBlk ? false,
1617
withGpu ? false,
1718
withSound ? false,
1819
withNet ? false,
@@ -21,13 +22,13 @@
2122

2223
stdenv.mkDerivation (finalAttrs: {
2324
pname = "libkrun";
24-
version = "1.9.8";
25+
version = "1.11.2";
2526

2627
src = fetchFromGitHub {
2728
owner = "containers";
2829
repo = "libkrun";
2930
tag = "v${finalAttrs.version}";
30-
hash = "sha256-a5ot5ad8boANK3achn6PJ52k/xmxawbTM0/hEEC/fss=";
31+
hash = "sha256-B11f7uG/oODwkME2rauCFbVysxUtUrUmd6RKeuBdnUU=";
3132
};
3233

3334
outputs = [
@@ -37,9 +38,19 @@ stdenv.mkDerivation (finalAttrs: {
3738

3839
cargoDeps = rustPlatform.fetchCargoVendor {
3940
inherit (finalAttrs) src;
40-
hash = "sha256-X1NPZQaXFBw9IKD2DbBCPug0WDjv8XnpefbA2RNJgFU=";
41+
hash = "sha256-bcHy8AfO9nzSZKoFlEpPKvwupt3eMb+A2rHDaUzO3/U=";
4142
};
4243

44+
# Make sure libkrunfw can be found by dlopen()
45+
# FIXME: This wasn't needed previously. What changed?
46+
env.RUSTFLAGS = toString (
47+
map (flag: "-C link-arg=" + flag) [
48+
"-Wl,--push-state,--no-as-needed"
49+
"-lkrunfw"
50+
"-Wl,--pop-state"
51+
]
52+
);
53+
4354
nativeBuildInputs = [
4455
rustPlatform.cargoSetupHook
4556
rustPlatform.bindgenHook
@@ -65,15 +76,16 @@ stdenv.mkDerivation (finalAttrs: {
6576
[
6677
"PREFIX=${placeholder "out"}"
6778
]
79+
++ lib.optional withBlk "BLK=1"
6880
++ lib.optional withGpu "GPU=1"
6981
++ lib.optional withSound "SND=1"
7082
++ lib.optional withNet "NET=1"
7183
++ lib.optional sevVariant "SEV=1";
7284

7385
postInstall = ''
7486
mkdir -p $dev/lib/pkgconfig
75-
mv $out/lib64/pkgconfig $dev/lib/pkgconfig
76-
mv $out/include $dev/include
87+
mv $out/lib64/pkgconfig $dev/lib/
88+
mv $out/include $dev/
7789
'';
7890

7991
meta = with lib; {
@@ -83,6 +95,7 @@ stdenv.mkDerivation (finalAttrs: {
8395
maintainers = with maintainers; [
8496
nickcao
8597
RossComputerGuy
98+
nrabulinski
8699
];
87100
platforms = libkrunfw.meta.platforms;
88101
};

pkgs/by-name/li/libkrunfw/package.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
stdenv.mkDerivation (finalAttrs: {
1717
pname = "libkrunfw";
18-
version = "4.5.1";
18+
version = "4.9.0";
1919

2020
src = fetchFromGitHub {
2121
owner = "containers";
2222
repo = "libkrunfw";
2323
tag = "v${finalAttrs.version}";
24-
hash = "sha256-GFfBiGMOyBwMKjpD1kj3vRpvjR0ydji3QNDyoOQoQsw=";
24+
hash = "sha256-wmvjex68Mh7qehA33WNBYHhV9Q/XWLixokuGWnqJ3n0=";
2525
};
2626

2727
kernelSrc = fetchurl {
28-
url = "mirror://kernel/linux/kernel/v6.x/linux-6.6.59.tar.xz";
29-
hash = "sha256-I2FoCNjAjxKBX/iY9O20wROXorKEPQKe5iRS0hgzp20=";
28+
url = "mirror://kernel/linux/kernel/v6.x/linux-6.12.20.tar.xz";
29+
hash = "sha256-Iw6JsHsKuC508H7MG+4xBdyoHQ70qX+QCSnEBySbasc=";
3030
};
3131

3232
postPatch = ''
@@ -71,6 +71,7 @@ stdenv.mkDerivation (finalAttrs: {
7171
maintainers = with maintainers; [
7272
nickcao
7373
RossComputerGuy
74+
nrabulinski
7475
];
7576
platforms = [ "x86_64-linux" ] ++ lib.optionals (!sevVariant) [ "aarch64-linux" ];
7677
};

pkgs/by-name/mu/muvm/package.nix

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
rustPlatform,
6+
libkrun,
7+
passt,
8+
dhcpcd,
9+
systemd,
10+
udev,
11+
pkg-config,
12+
procps,
13+
fex,
14+
writeShellApplication,
15+
coreutils,
16+
makeBinaryWrapper,
17+
# TODO: Enable again when sommelier is not broken.
18+
# For now, don't give false impression of sommelier being supported.
19+
# sommelier,
20+
# withSommelier ? false,
21+
}:
22+
let
23+
# TODO: Setup setuid wrappers.
24+
# E.g. FEX needs fusermount for rootfs functionality
25+
initScript = writeShellApplication {
26+
name = "muvm-init";
27+
runtimeInputs = [
28+
coreutils
29+
];
30+
text = ''
31+
if [[ ! -f /etc/NIXOS ]]; then exit; fi
32+
33+
ln -s /run/muvm-host/run/current-system /run/current-system
34+
# Only create the symlink if that path exists on the host and is a directory.
35+
if [[ -d /run/muvm-host/run/opengl-driver ]]; then ln -s /run/muvm-host/run/opengl-driver /run/opengl-driver; fi
36+
'';
37+
};
38+
binPath = [
39+
dhcpcd
40+
passt
41+
(placeholder "out")
42+
] ++ lib.optionals stdenv.isAarch64 [ fex ];
43+
wrapArgs = lib.escapeShellArgs [
44+
"--prefix"
45+
"PATH"
46+
":"
47+
(lib.makeBinPath binPath)
48+
"--add-flags"
49+
"--execute-pre=${lib.getExe initScript}"
50+
];
51+
in
52+
rustPlatform.buildRustPackage rec {
53+
pname = "muvm";
54+
version = "0.4.1";
55+
56+
src = fetchFromGitHub {
57+
owner = "AsahiLinux";
58+
repo = pname;
59+
rev = "muvm-${version}";
60+
hash = "sha256-1XPhVEj7iqTxdWyYwNk6cbb9VRGuhpvvowYDPJb1cWU=";
61+
};
62+
63+
useFetchCargoVendor = true;
64+
cargoHash = "sha256-fkvdS0c1Ib8Kto44ou06leXy731cpMHXevyFR5RROt4=";
65+
66+
postPatch =
67+
''
68+
substituteInPlace crates/muvm/src/guest/bin/muvm-guest.rs \
69+
--replace-fail "/usr/lib/systemd/systemd-udevd" "${systemd}/lib/systemd/systemd-udevd"
70+
71+
substituteInPlace crates/muvm/src/monitor.rs \
72+
--replace-fail "/sbin/sysctl" "${lib.getExe' procps "sysctl"}"
73+
''
74+
# Only patch FEX path if we're aarch64, otherwise we don't want the derivation to pull in FEX in any way
75+
+ lib.optionalString stdenv.isAarch64 ''
76+
substituteInPlace crates/muvm/src/guest/mount.rs \
77+
--replace-fail "/usr/share/fex-emu" "${fex}/share/fex-emu"
78+
'';
79+
80+
nativeBuildInputs = [
81+
rustPlatform.bindgenHook
82+
makeBinaryWrapper
83+
pkg-config
84+
];
85+
86+
buildInputs = [
87+
(libkrun.override {
88+
withBlk = true;
89+
withGpu = true;
90+
withNet = true;
91+
})
92+
udev
93+
];
94+
95+
postFixup = ''
96+
wrapProgram $out/bin/muvm ${wrapArgs}
97+
'';
98+
99+
meta = {
100+
description = "Run programs from your system in a microVM";
101+
homepage = "https://github.com/AsahiLinux/muvm";
102+
license = lib.licenses.mit;
103+
maintainers = with lib.maintainers; [
104+
RossComputerGuy
105+
nrabulinski
106+
];
107+
inherit (libkrun.meta) platforms;
108+
mainProgram = "muvm";
109+
};
110+
}

pkgs/top-level/aliases.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ mapAliases {
917917
kramdown-rfc2629 = throw "'kramdown-rfc2629' has been renamed to/replaced by 'rubyPackages.kramdown-rfc2629'"; # Converted to throw 2024-10-17
918918
krb5Full = krb5;
919919
krita-beta = throw "'krita-beta' has been renamed to/replaced by 'krita'"; # Converted to throw 2024-10-17
920+
krun = throw "'krun' has been renamed to/replaced by 'muvm'"; # Added 2025-05-01
920921
kubei = kubeclarity; # Added 2023-05-20
921922
kubo-migrator-all-fs-repo-migrations = kubo-fs-repo-migrations; # Added 2024-09-24
922923

0 commit comments

Comments
 (0)