From 0d357deb1ec24700cc79f0493a95b99e352b1651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 6 Dec 2023 14:28:35 +0100 Subject: [PATCH] add qemu-wayland --- pkgs/aemu/default.nix | 19 +++ pkgs/flake-module.nix | 10 ++ pkgs/gfxstream/default.nix | 49 +++++++ pkgs/qemu-wayland/default.nix | 15 ++ pkgs/rutabaga-gfx-ffi/Cargo.lock | 222 ++++++++++++++++++++++++++++++ pkgs/rutabaga-gfx-ffi/default.nix | 34 +++++ 6 files changed, 349 insertions(+) create mode 100644 pkgs/aemu/default.nix create mode 100644 pkgs/gfxstream/default.nix create mode 100644 pkgs/qemu-wayland/default.nix create mode 100644 pkgs/rutabaga-gfx-ffi/Cargo.lock create mode 100644 pkgs/rutabaga-gfx-ffi/default.nix diff --git a/pkgs/aemu/default.nix b/pkgs/aemu/default.nix new file mode 100644 index 00000000..0788b537 --- /dev/null +++ b/pkgs/aemu/default.nix @@ -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 ]; +} diff --git a/pkgs/flake-module.nix b/pkgs/flake-module.nix index b3792a8f..3cefa2a9 100644 --- a/pkgs/flake-module.nix +++ b/pkgs/flake-module.nix @@ -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; diff --git a/pkgs/gfxstream/default.nix b/pkgs/gfxstream/default.nix new file mode 100644 index 00000000..d9cfeed2 --- /dev/null +++ b/pkgs/gfxstream/default.nix @@ -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 + ]; +} diff --git a/pkgs/qemu-wayland/default.nix b/pkgs/qemu-wayland/default.nix new file mode 100644 index 00000000..8c400456 --- /dev/null +++ b/pkgs/qemu-wayland/default.nix @@ -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 ]; +}) diff --git a/pkgs/rutabaga-gfx-ffi/Cargo.lock b/pkgs/rutabaga-gfx-ffi/Cargo.lock new file mode 100644 index 00000000..2ffebbd3 --- /dev/null +++ b/pkgs/rutabaga-gfx-ffi/Cargo.lock @@ -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", +] diff --git a/pkgs/rutabaga-gfx-ffi/default.nix b/pkgs/rutabaga-gfx-ffi/default.nix new file mode 100644 index 00000000..eae5ebdb --- /dev/null +++ b/pkgs/rutabaga-gfx-ffi/default.nix @@ -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 ]; +}