lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 109 lines 2.7 kB view raw
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}: 22let 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 ] 43 ++ lib.optionals stdenv.hostPlatform.isAarch64 [ fex ]; 44 wrapArgs = lib.escapeShellArgs [ 45 "--prefix" 46 "PATH" 47 ":" 48 (lib.makeBinPath binPath) 49 "--add-flags" 50 "--execute-pre=${lib.getExe initScript}" 51 ]; 52in 53rustPlatform.buildRustPackage rec { 54 pname = "muvm"; 55 version = "0.4.1"; 56 57 src = fetchFromGitHub { 58 owner = "AsahiLinux"; 59 repo = "muvm"; 60 rev = "muvm-${version}"; 61 hash = "sha256-1XPhVEj7iqTxdWyYwNk6cbb9VRGuhpvvowYDPJb1cWU="; 62 }; 63 64 cargoHash = "sha256-fkvdS0c1Ib8Kto44ou06leXy731cpMHXevyFR5RROt4="; 65 66 postPatch = '' 67 substituteInPlace crates/muvm/src/guest/bin/muvm-guest.rs \ 68 --replace-fail "/usr/lib/systemd/systemd-udevd" "${systemd}/lib/systemd/systemd-udevd" 69 70 substituteInPlace crates/muvm/src/monitor.rs \ 71 --replace-fail "/sbin/sysctl" "${lib.getExe' procps "sysctl"}" 72 '' 73 # Only patch FEX path if we're aarch64, otherwise we don't want the derivation to pull in FEX in any way 74 + lib.optionalString stdenv.hostPlatform.isAarch64 '' 75 substituteInPlace crates/muvm/src/guest/mount.rs \ 76 --replace-fail "/usr/share/fex-emu" "${fex}/share/fex-emu" 77 ''; 78 79 nativeBuildInputs = [ 80 rustPlatform.bindgenHook 81 makeBinaryWrapper 82 pkg-config 83 ]; 84 85 buildInputs = [ 86 (libkrun.override { 87 withBlk = true; 88 withGpu = true; 89 withNet = true; 90 }) 91 udev 92 ]; 93 94 postFixup = '' 95 wrapProgram $out/bin/muvm ${wrapArgs} 96 ''; 97 98 meta = { 99 description = "Run programs from your system in a microVM"; 100 homepage = "https://github.com/AsahiLinux/muvm"; 101 license = lib.licenses.mit; 102 maintainers = with lib.maintainers; [ 103 RossComputerGuy 104 nrabulinski 105 ]; 106 inherit (libkrun.meta) platforms; 107 mainProgram = "muvm"; 108 }; 109}