diff --git a/device/testing/device-xiaomi-sagit/APKBUILD b/device/testing/device-xiaomi-sagit/APKBUILD
new file mode 100644
index 0000000000000000000000000000000000000000..3d5e358c6853023a63fcc1d484bad24075cbd848
--- /dev/null
+++ b/device/testing/device-xiaomi-sagit/APKBUILD
@@ -0,0 +1,50 @@
+# Reference: <https://postmarketos.org/devicepkg>
+pkgname="device-xiaomi-sagit"
+pkgdesc="Xiaomi Mi 6"
+pkgver=1
+pkgrel=0
+url="https://postmarketos.org"
+license="MIT"
+arch="aarch64"
+options="!check !archcheck"
+depends="
+	mkbootimg
+	postmarketos-base
+	postmarketos-update-kernel
+	linux-postmarketos-qcom-msm8998
+	soc-qcom-sdm845
+"
+makedepends="devicepkg-dev"
+source="
+	deviceinfo
+	phoc.ini
+"
+subpackages="
+	$pkgname-nonfree-firmware:nonfree_firmware
+	$pkgname-phosh
+"
+
+build() {
+	devicepkg_build $startdir $pkgname
+}
+
+package() {
+	devicepkg_package $startdir $pkgname
+}
+
+nonfree_firmware() {
+	pkgdesc="Firmware for GPU, Wi-Fi, Bluetooth etc. (mainline only, also needed for osk-sdl)"
+	depends="firmware-xiaomi-sagit"
+	mkdir "$subpkgdir"
+}
+
+phosh() {
+	install_if="$pkgname postmarketos-ui-phosh"
+	install -Dm644 "$srcdir"/phoc.ini \
+		"$subpkgdir"/etc/phosh/phoc.ini
+}
+
+sha512sums="
+5b676963714dddf6cdb322a1ffbf38406a7edf2fc0a5795896cbbf2b28ac412d00f95611c74b60622ba020345eed85e8cbd1e29a040b09cfc4c1b16b1bdb15bc  deviceinfo
+2288f08a44aae5136c0c0c846501c2bd4bcb10f05454b40c6e4490d398385b8a7129216047b5eb7982ca6d62d3aa71f3e18bfb8661d0cd32c8a600685ca0da48  phoc.ini
+"
diff --git a/device/testing/device-xiaomi-sagit/deviceinfo b/device/testing/device-xiaomi-sagit/deviceinfo
new file mode 100644
index 0000000000000000000000000000000000000000..46f19d2f838b1489a44661b2e429751f758106b6
--- /dev/null
+++ b/device/testing/device-xiaomi-sagit/deviceinfo
@@ -0,0 +1,42 @@
+# Reference: <https://postmarketos.org/deviceinfo>
+# Please use double quotes only. You can source this file in shell scripts.
+
+deviceinfo_format_version="0"
+deviceinfo_name="Xiaomi Mi 6"
+deviceinfo_manufacturer="Xiaomi"
+deviceinfo_codename="xiaomi-sagit"
+deviceinfo_year="2017"
+deviceinfo_arch="aarch64"
+
+# Device related
+deviceinfo_gpu_accelerated="true"
+deviceinfo_chassis="handset"
+deviceinfo_keyboard="false"
+deviceinfo_external_storage="false"
+deviceinfo_screen_width="1080"
+deviceinfo_screen_height="1920"
+
+# Bootloader related
+deviceinfo_flash_method="fastboot"
+deviceinfo_kernel_cmdline="clk_ignore_unused console=tty1"
+deviceinfo_generate_bootimg="true"
+deviceinfo_bootimg_qcdt="false"
+deviceinfo_bootimg_dtb_second="false"
+deviceinfo_flash_offset_base="0x00000000"
+deviceinfo_flash_offset_kernel="0x00008000"
+deviceinfo_flash_offset_ramdisk="0x01000000"
+deviceinfo_flash_offset_second="0x00f00000"
+deviceinfo_flash_offset_tags="0x00000100"
+deviceinfo_flash_pagesize="4096"
+deviceinfo_flash_sparse="true"
+# Kernel options
+deviceinfo_dtb="qcom/msm8998-oneplus-cheeseburger"
+deviceinfo_append_dtb="true"
+deviceinfo_flash_kernel_on_update="true"
+
+# Initramfs
+deviceinfo_modules_initfs_mainline="panel-jdi-fhd-r63452 msm i2c-qup rmi_i2c qcom_spmi_fg qcom_spmi_haptics"
+deviceinfo_mesa_driver="msm"
+
+# Required for devices using UFS as storage (instead of e.g. eMMC)
+deviceinfo_rootfs_image_sector_size="4096"
diff --git a/device/testing/device-xiaomi-sagit/phoc.ini b/device/testing/device-xiaomi-sagit/phoc.ini
new file mode 100644
index 0000000000000000000000000000000000000000..5e1c09aa758f3f9d1ac31cc89e1736dcbe3d41a1
--- /dev/null
+++ b/device/testing/device-xiaomi-sagit/phoc.ini
@@ -0,0 +1,5 @@
+# /etc/phosh/phoc.ini
+# Overwrites defaults in /usr/share/phosh/phoc.ini
+
+[output:DSI-1]
+scale = 2.5
diff --git a/device/testing/firmware-xiaomi-sagit/30-gpu-firmware.files b/device/testing/firmware-xiaomi-sagit/30-gpu-firmware.files
new file mode 100644
index 0000000000000000000000000000000000000000..5f4dfe18420d4aa434cb814715173d0cc1d19e5f
--- /dev/null
+++ b/device/testing/firmware-xiaomi-sagit/30-gpu-firmware.files
@@ -0,0 +1,4 @@
+/lib/firmware/qcom/a530_pfp.fw
+/lib/firmware/qcom/a530_pm4.fw
+/lib/firmware/qcom/a540_gpmu.fw2
+/lib/firmware/qcom/a540_zap.mbn
diff --git a/device/testing/firmware-xiaomi-sagit/APKBUILD b/device/testing/firmware-xiaomi-sagit/APKBUILD
new file mode 100644
index 0000000000000000000000000000000000000000..6e838deb4f24a6af5cf1e661ef5bf6d09e536f74
--- /dev/null
+++ b/device/testing/firmware-xiaomi-sagit/APKBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Degdag Mohamed <degdagmohamed@gmail.com>
+pkgname=firmware-xiaomi-sagit
+pkgver=1
+pkgrel=0
+_commit="6dd776c42642c444eafffadb248fd119b777b514"
+pkgdesc="Firmware for Xiaomi Mi 6"
+url="https://github.com/degdag/firmware-mainline-xiaomi-mi6"
+# Conflicts with ath10k/WCN3990/hw1.0/firmware-5.bin, qca/cr{btfw21.tlv,nv21.bin} & qcom/a530_p{fp,m4}.fw
+replaces="linux-firmware-ath10k linux-firmware-qca linux-firmware-qcom"
+arch="aarch64"
+depends="soc-qcom-sdm845-nonfree-firmware qcom-diag"
+install="$pkgname.post-install"
+license="proprietary"
+options="!check !archcheck !strip !tracedeps pmb:cross-native"
+source="
+	$pkgname-$_commit.tar.gz::https://github.com/degdag/firmware-mainline-xiaomi-mi6/archive/$_commit.tar.gz
+	30-gpu-firmware.files
+	firmware.files
+"
+subpackages="$pkgname-initramfs:firmware_initramfs"
+builddir="$srcdir/firmware-mainline-xiaomi-mi6-$_commit"
+
+package() {
+	while IFS="" read -r fw; do
+		install -Dm644 "$fw" "$pkgdir/lib/firmware/$fw"
+	done < "$srcdir"/firmware.files
+}
+
+firmware_initramfs() {
+	pkgdesc="Files to be included in the initramfs to support osk-sdl"
+	depends="$pkgname mesa-egl mesa-gbm"
+	install_if="$pkgname"
+
+	install -Dm644 "$srcdir"/30-gpu-firmware.files \
+		"$subpkgdir"/etc/postmarketos-mkinitfs/files/30-gpu-firmware.files
+}
+
+sha512sums="
+36e36ab33fc0f1150a361829af86559eeec6f1e8e3b036ed9cbb37040110b772e9758007c2ce090d88b0dd5e1e79b4e3f86d4994f42742208bb9ed23c11499bb  firmware-xiaomi-sagit-6dd776c42642c444eafffadb248fd119b777b514.tar.gz
+974b7bcef52b4ae6d6fa11212ede1ddc9a9944dc3d6b066b0813072d8a9586929db8052670d98277db15cc1e2aa2d731c97c9c3d443f26bd3afab7e885230cba  30-gpu-firmware.files
+7afbe7c43b5d30e0922694e70435419d2c37eff1571c60f33f64f4b693ca3d83a1b81452b8567287ea4f2d5e57a0c97870d8d81e591614d8fa1b3e745d573b06  firmware.files
+"
diff --git a/device/testing/firmware-xiaomi-sagit/firmware-xiaomi-sagit.post-install b/device/testing/firmware-xiaomi-sagit/firmware-xiaomi-sagit.post-install
new file mode 100644
index 0000000000000000000000000000000000000000..268eff4bd086bf1036af762447e4867d9c5a5dc6
--- /dev/null
+++ b/device/testing/firmware-xiaomi-sagit/firmware-xiaomi-sagit.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+# The Wi-Fi firmware will keep crashing if diag-router isn't running
+rc-update add diag-router boot
diff --git a/device/testing/firmware-xiaomi-sagit/firmware.files b/device/testing/firmware-xiaomi-sagit/firmware.files
new file mode 100644
index 0000000000000000000000000000000000000000..d793730b1c1323c0e2f2cc25fc4a0d0a65bd9561
--- /dev/null
+++ b/device/testing/firmware-xiaomi-sagit/firmware.files
@@ -0,0 +1,17 @@
+ath10k/WCN3990/hw1.0/board-2.bin
+ath10k/WCN3990/hw1.0/firmware-5.bin
+qca/crbtfw21.tlv
+qca/crnv21.bin
+qcom/a530_pfp.fw
+qcom/a530_pm4.fw
+qcom/a540_gpmu.fw2
+qcom/a540_zap.mbn
+qcom/msm8998/xiaomi/adsp.mbn
+qcom/msm8998/xiaomi/adspua.jsn
+qcom/msm8998/xiaomi/ipa_fws.mbn
+qcom/msm8998/xiaomi/mba.mbn
+qcom/msm8998/xiaomi/modem.mbn
+qcom/msm8998/xiaomi/modemuw.jsn
+qcom/msm8998/xiaomi/slpi_v2.mbn
+qcom/msm8998/xiaomi/slpius.jsn
+qcom/msm8998/xiaomi/wlanmdsp.mbn