1
0
forked from clan/clan-core

Compare commits

...

2 Commits

Author SHA1 Message Date
bfc6686bc9 wip 2023-12-06 15:02:34 +01:00
0d357deb1e add qemu-wayland 2023-12-06 14:30:57 +01:00
7 changed files with 386 additions and 22 deletions

19
pkgs/aemu/default.nix Normal file
View File

@ -0,0 +1,19 @@
{ clangStdenv
, fetchgit
, cmake
}:
clangStdenv.mkDerivation {
pname = "aemu";
version = "unstable-2023-11-10";
src = fetchgit {
url = "https://android.googlesource.com/platform/hardware/google/aemu";
rev = "ed69e33fb47e6cbe1b1d07c63d4d293dabc770f6";
hash = "sha256-HYwGT48fPC3foqYvhw+RUsnkoEHgQXfMFGQVSpDu4v4=";
};
cmakeFlags = [
"-DAEMU_COMMON_GEN_PKGCONFIG=ON"
"-DAEMU_COMMON_BUILD_CONFIG=gfxstream"
];
nativeBuildInputs = [ cmake ];
}

View File

@ -28,15 +28,17 @@ def qemu_command(
f'init={nixos_config["toplevel"]}/init',
f'regInfo={nixos_config["regInfo"]}/registration',
"console=ttyS0,115200n8",
"console=tty0",
# "console=tty0",
]
# fmt: off
command = [
"qemu-kvm",
#"/nix/store/16v6fajw05bw5ay0263mbxglm3ssqh34-qemu-host-cpu-only-8.1.2/bin/qemu-system-x86_64",
"/home/joerg/git/qemu/build/qemu-system-x86_64",
"-name", vm.flake_attr,
"-m", f'{nixos_config["memorySize"]}M',
"-smp", str(nixos_config["cores"]),
"-cpu", "max",
"-enable-kvm",
"-device", "virtio-rng-pci",
"-net", "nic,netdev=user.0,model=virtio",
"-netdev", "user,id=user.0",
@ -49,7 +51,7 @@ def qemu_command(
"-device", "virtio-keyboard",
# TODO: we also need to fixup timezone than...
# "-rtc", "base=localtime,clock=host,driftfix=slew",
"-vga", "virtio",
#"-vga", "virtio",
"-usb", "-device", "usb-tablet,bus=usb-bus.0",
"-kernel", f'{nixos_config["toplevel"]}/kernel',
"-initrd", nixos_config["initrd"],
@ -60,25 +62,32 @@ def qemu_command(
# fmt: off
command.extend(
[
"-audiodev", "spice,id=audio0",
"-device", "intel-hda",
"-device", "hda-duplex,audiodev=audio0",
#"-audiodev", "spice,id=audio0",
#"-device", "intel-hda",
#"-device", "hda-duplex,audiodev=audio0",
#"-display", "gtk,gl=on",
"-nographic",
#-nographic -serial null -enable-kvm \
#-device virtio-serial \
#-chardev stdio,mux=on,id=char0,signal=off \
#-mon chardev=char0,mode=readline \
"-vga", "none",
"-device", "virtio-gpu-gl",
"-display", "spice-app,gl=on",
"-device", "virtio-serial-pci",
"-chardev", "spicevmc,id=vdagent0,name=vdagent",
"-device", "virtserialport,chardev=vdagent0,name=com.redhat.spice.0",
"-device", "qemu-xhci,id=spicepass",
"-chardev", "spicevmc,id=usbredirchardev1,name=usbredir",
"-device", "usb-redir,chardev=usbredirchardev1,id=usbredirdev1",
"-chardev", "spicevmc,id=usbredirchardev2,name=usbredir",
"-device", "usb-redir,chardev=usbredirchardev2,id=usbredirdev2",
"-chardev", "spicevmc,id=usbredirchardev3,name=usbredir",
"-device", "usb-redir,chardev=usbredirchardev3,id=usbredirdev3",
"-device", "pci-ohci,id=smartpass",
"-device", "usb-ccid",
"-chardev", "spicevmc,id=ccid,name=smartcard",
"-device", "virtio-gpu-rutabaga,gfxstream-vulkan=on,cross-domain=on,hostmem=4G,wsi=headless",
#"-device", "virtio-gpu-gl",
#"-display", "spice-app,gl=on",
#"-device", "virtio-serial-pci",
#"-chardev", "spicevmc,id=vdagent0,name=vdagent",
#"-device", "virtserialport,chardev=vdagent0,name=com.redhat.spice.0",
#"-device", "qemu-xhci,id=spicepass",
#"-chardev", "spicevmc,id=usbredirchardev1,name=usbredir",
#"-device", "usb-redir,chardev=usbredirchardev1,id=usbredirdev1",
#"-chardev", "spicevmc,id=usbredirchardev2,name=usbredir",
#"-device", "usb-redir,chardev=usbredirchardev2,id=usbredirdev2",
#"-chardev", "spicevmc,id=usbredirchardev3,name=usbredir",
#"-device", "usb-redir,chardev=usbredirchardev3,id=usbredirdev3",
#"-device", "pci-ohci,id=smartpass",
#"-device", "usb-ccid",
#"-chardev", "spicevmc,id=ccid,name=smartcard",
]
)
# fmt: on
@ -226,8 +235,14 @@ class BuildVmTask(BaseTask):
env[
"XDG_DATA_DIRS"
] = f"{remote_viewer_mimetypes}:{env.get('XDG_DATA_DIRS', '')}"
env[
"LD_LIBRARY_PATH"
] = "/nix/store/r7j600ar9fnnp4jngvhlx55giv46798r-vulkan-loader-1.3.268.0/lib"
print(env["XDG_DATA_DIRS"])
cmd.run(nix_shell(packages, qemu_cmd), name="qemu", env=env)
import subprocess
subprocess.run(qemu_cmd, env=env)
# cmd.run(nix_shell(packages, qemu_cmd), name="qemu", env=env)
def run_vm(

View File

@ -15,6 +15,16 @@
inherit (config.packages) tea-create-pr;
};
pending-reviews = pkgs.callPackage ./pending-reviews { };
aemu = pkgs.callPackage ./aemu { };
gfxstream = pkgs.callPackage ./gfxstream {
inherit (config.packages) aemu;
};
rutabaga-gfx-ffi = pkgs.callPackage ./rutabaga-gfx-ffi {
inherit (config.packages) gfxstream aemu;
};
qemu-wayland = pkgs.callPackage ./qemu-wayland {
inherit (config.packages) rutabaga-gfx-ffi;
};
nix-unit = pkgs.callPackage ./nix-unit { };
meshname = pkgs.callPackage ./meshname { };
inherit (pkgs.callPackages ./node-packages { }) prettier-plugin-tailwindcss;

View File

@ -0,0 +1,49 @@
{ clangStdenv
, fetchgit
, aemu
, meson
, pkg-config
, ninja
, python3
, vulkan-headers
, vulkan-utility-libraries
, renderdoc
, glm
, libglvnd
, xorg
}:
clangStdenv.mkDerivation {
pname = "gfxstream";
version = "unstable-2023-11-29";
src = fetchgit {
url = "https://android.googlesource.com/platform/hardware/google/gfxstream";
rev = "45c27965ee5121651946f54a42b3297b26047955";
hash = "sha256-nJVVePNro+sL7jC+ehe5Am2jWo9BK6H1AUSzoP7J1ss=";
};
postPatch = ''
ln common/etc/etc.cpp host/compressedTextureFormats/etc.cpp
ln common/etc/etc.cpp host/gl/glestranslator/GLcommon/etc.cpp
'';
preConfigure = ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$(pwd)/common/etc/include"
'';
buildInputs = [
aemu
glm
libglvnd
renderdoc
vulkan-headers
vulkan-utility-libraries
xorg.libX11
];
mesonFlags = [
"-Ddecoders=gles,vulkan,composer"
];
nativeBuildInputs = [
meson
pkg-config
ninja
python3
];
}

View File

@ -0,0 +1,15 @@
{ qemu_kvm, rutabaga-gfx-ffi, fetchurl, lib, vulkan-loader }:
qemu_kvm.overrideAttrs (old: {
src = fetchurl {
url = "https://download.qemu.org/qemu-8.2.0-rc2.tar.xz";
hash = "sha256-AbQozd8IQNDBsA6/zE98xQboh4dWSk0/V/IsflCju9g=";
};
postFixup = (old.postFixup or "") + ''
for bin in $out/bin/qemu-system-*; do
wrapProgram $bin \
--prefix LD_LIBRARY_PATH ':' ${lib.getLib vulkan-loader}/lib
done
'';
buildInputs = old.buildInputs ++ [ rutabaga-gfx-ffi ];
})

222
pkgs/rutabaga-gfx-ffi/Cargo.lock generated Normal file
View File

@ -0,0 +1,222 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anyhow"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "libc"
version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "nix"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags",
"cfg-if",
"libc",
"memoffset",
"pin-utils",
]
[[package]]
name = "once_cell"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "proc-macro2"
version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "remain"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bce3a7139d2ee67d07538ee5dba997364fbc243e7e7143e96eb830c74bfaa082"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "rutabaga_gfx"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "450c21b372f2bc0adafa01a5293a5b8ed2f1b691b373a97a9c60367e75c07b6d"
dependencies = [
"anyhow",
"cfg-if",
"libc",
"log",
"nix",
"pkg-config",
"remain",
"thiserror",
"winapi",
"zerocopy",
]
[[package]]
name = "rutabaga_gfx_ffi"
version = "0.1.2"
dependencies = [
"libc",
"log",
"once_cell",
"rutabaga_gfx",
]
[[package]]
name = "syn"
version = "2.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "zerocopy"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956"
dependencies = [
"byteorder",
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@ -0,0 +1,34 @@
{ aemu
, rustPlatform
, fetchFromGitHub
, pkg-config
, gfxstream
, libdrm
}:
rustPlatform.buildRustPackage {
pname = "rutabaga_gfx_ffi";
version = "unstable-2023-12-05";
src = fetchFromGitHub {
owner = "google";
repo = "crosvm";
rev = "a10c83864e1d6e47773ca06e47ada4f888b30d82";
hash = "sha256-Dd0oCgCL5LNxDuOJ6hyCXeqGyKBP0AqKamQTKXqNcjk=";
fetchSubmodules = true;
};
buildPhase = ''
cd rutabaga_gfx/ffi
make build
'';
installPhase = ''
make install prefix=$out
'';
cargoHash = "sha256-oh49o/WjfT9xsQH4SUtFwNl6H3pX5Wio3FzKw+slJcQ=";
nativeBuildInputs = [ pkg-config ];
buildInputs = [ gfxstream aemu libdrm ];
}