Squashed commit of the following:
commit74b2428653Author: Roman Lubij <roman.lubij@gmail.com> Date: Fri May 22 12:10:36 2026 +0200 flake.nix: Add cross-compilation support for aarch64-linux; hardware-configuration.nix: Refactor kernel package handling for cross-compilation commita86ad5e9d8Author: Roman Lubij <roman.lubij@gmail.com> Date: Fri May 22 11:53:00 2026 +0200 configuration.nix: Add nh configuration for cleaning and enabling flake commit458cf43e1bAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Fri May 22 11:49:23 2026 +0200 configuration.nix: Change user from 'jax' to 'nixos'; flake.nix: Update configuration copying to user's home directory; hardware-configuration.nix: Refactor cross-compilation logic for kernel packages commit0e97e81190Author: Roman Lubij <roman.lubij@gmail.com> Date: Fri May 22 11:25:54 2026 +0200 configuration.nix: Update console font to use terminus_font package; flake.nix: Set system to aarch64-linux; hardware-configuration.nix: Adjust kernel package imports for cross-compilation commitd1676568c1Author: Roman Lubij <roman.lubij@gmail.com> Date: Fri May 22 10:48:28 2026 +0200 Panel wooooorks commit1413701ab0Author: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 23:59:27 2026 +0200 hardware-configuration.nix: Add "msm" to kernel modules; pipa.config: Change CONFIG_DRM_MSM to module commitfc83ffe47fAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 23:46:14 2026 +0200 flake.nix: Update image formatting commands to include sector size commit56346fab48Author: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 23:46:09 2026 +0200 hardware-configuration.nix: Update kernel parameters and refine file system configurations commit36a385e385Author: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 23:28:43 2026 +0200 configuration.nix: Add USB interface IP configuration; hardware-configuration.nix: Update kernel parameters and modules commit055168d3ddAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 23:09:21 2026 +0200 firmware.nix and kernel.nix: Switch from GitHub to Gitea for source fetching commit4d0ec955a1Author: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 17:47:40 2026 +0200 configuration.nix: Add i18n and console settings; flake.nix: Introduce build script for image creation; hardware-configuration.nix: Update kernel modules; kernel.nix: Simplify kernel versioning commit0e0ebff7d0Author: Roman Lubij <roman.lubij@gmail.com> Date: Thu May 21 17:47:33 2026 +0200 firmware.nix: Update hash and refine install phase for firmware copying commit6fd385eb8cAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 21:13:55 2026 +0200 Kernel build started successfully, hopefully itll stay that way commit7cf35a678eAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 20:04:45 2026 +0200 ye commita045ef453fAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 20:03:08 2026 +0200 flake.lock: Add Flake lock file updates: • Added input 'nixpkgs': 'github:NixOS/nixpkgs/687f05a9184cad4eaf905c48b63649e3a86f5433?narHash=sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg%3D' (2026-05-18) commitac1df2ea08Author: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 20:01:29 2026 +0200 Init v3 commitab42287e3dAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 19:47:21 2026 +0200 Fuck the old config commit4038b7fb6eAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Wed May 20 19:46:41 2026 +0200 Fuck this shit I'm out commit2439ce45e4Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 18:12:38 2026 +0200 Enhance firmware flashing and kernel parameters for Xiaomi Pad 6 commitda3a1f53e9Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:36:45 2026 +0200 Add flash target commitfc5f27117bAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:36:40 2026 +0200 Add some more modules. Let's pray... commita2cac5f72bAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:36:29 2026 +0200 Yeet the sandbox commit4d536d26abAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:11:15 2026 +0200 Oops, add inputs commitab98a3a7feAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:08:14 2026 +0200 actually not needed, cool commit600b9b465fAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:07:19 2026 +0200 Add xiaomi-pipa-firmware to system packages and update firmware configuration commit1c9793efb3Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:05:55 2026 +0200 Add Nix package for Xiaomi Pad 6 firmware with installation steps commit71c8d1f4aaAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 16:01:50 2026 +0200 These firmware files should be in linux-firmware ready commit592db74e52Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 15:58:56 2026 +0200 Add pipa firmware commitb7e4fc4b41Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 15:55:09 2026 +0200 add linux-firmware commit29e47b262aAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 15:54:57 2026 +0200 Remove obsolete firmware files from the repository commit2c7f7599f5Author: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 15:34:25 2026 +0200 Refactor image creation script to enhance boot image handling and cleanup process commitef5161eaccAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Tue May 19 15:34:20 2026 +0200 Update initrd kernel modules and adjust file system configuration commitf49b1d0e62Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 23:05:13 2026 +0200 Clean up comments in configuration files for clarity and conciseness commit0a309ab4caAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 23:03:57 2026 +0200 Refactor boot configuration for improved kernel package handling and loader setup commitd2e29b17d0Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 22:58:10 2026 +0200 Refactor build script to enhance image creation and cleanup process commit411b847170Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 22:58:04 2026 +0200 Add initrd configuration to load essential drivers during boot commit5cdb91059dAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 22:25:30 2026 +0200 Drop separate boot part commit7215245e0dAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 22:05:48 2026 +0200 Somewhat working commit449a439bfaAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 21:43:07 2026 +0200 Shit builds v2 commit2762b036b2Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 21:15:43 2026 +0200 Refactor build script to improve cleanup and output directory handling commit41dcf0ed2aAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 21:15:38 2026 +0200 Add internationalization settings and timezone configuration commite3730c0c4eAuthor: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 20:00:49 2026 +0200 Add deployment script for building and flashing images commita0e3c1cb05Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 20:00:45 2026 +0200 Update bootloader configuration to use systemd-boot and adjust filesystem labels commit081b85f7e5Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 20:00:40 2026 +0200 Refactor Justfile to remove unused build targets and streamline build process commitc73a552c88Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 19:56:10 2026 +0200 Update gitignore commit357510eca5Author: Roman Lubij <roman.lubij@gmail.com> Date: Mon May 18 18:44:29 2026 +0200 Add GRUB config
This commit is contained in:
+4
-1
@@ -1,2 +1,5 @@
|
||||
result*
|
||||
pocketblue*
|
||||
pocketblue*
|
||||
mnt
|
||||
output.txt
|
||||
*.img
|
||||
@@ -1,5 +1,3 @@
|
||||
default: build-all
|
||||
|
||||
default_flags := ""
|
||||
|
||||
build flags=default_flags:
|
||||
@@ -8,18 +6,21 @@ build flags=default_flags:
|
||||
build-kernel flags=default_flags:
|
||||
nix run nixpkgs#nix-output-monitor -- build .#nixosConfigurations.pipa.config.boot.kernelPackages.kernel {{flags}} -o result-kernel
|
||||
|
||||
build-kernel-image flags=default_flags:
|
||||
nix run nixpkgs#nix-output-monitor -- build .#nixosConfigurations.pipa.config.system.build.android-bootimg {{flags}} -o result-boot
|
||||
build-rawImg flags=default_flags:
|
||||
nix run nixpkgs#nix-output-monitor -- build .#nixosConfigurations.pipa.config.system.build.rawImage {{flags}} -o result-raw
|
||||
|
||||
build-image flags=default_flags:
|
||||
nix run nixpkgs#nix-output-monitor -- build .#nixosConfigurations.pipa.config.system.build.sdImage {{flags}} -o result-image
|
||||
flash-all:
|
||||
fastboot flash fedora_boot images/boot.img
|
||||
fastboot flash fedora_root images/rootfs.sparse.img
|
||||
fastboot reboot
|
||||
|
||||
build-all flags=default_flags:
|
||||
just build-image {{flags}}
|
||||
just build-kernel-image {{flags}}
|
||||
flash-boot:
|
||||
fastboot flash fedora_boot images/boot.img
|
||||
fastboot reboot
|
||||
|
||||
build-partitions flags=default_flags:
|
||||
nix run nixpkgs#nix-output-monitor -- build .#nixosConfigurations.pipa.config.system.build.separated-images -o result-partitions {{flags}}
|
||||
flash-root:
|
||||
fastboot flash fedora_root images/rootfs.sparse.img
|
||||
fastboot reboot
|
||||
|
||||
format:
|
||||
alejandra .
|
||||
|
||||
+82
-10
@@ -1,24 +1,96 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
system.stateVersion = "26.05"; # Matches our 2026 build timeline
|
||||
networking = {
|
||||
hostName = "pipa";
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
networking.hostName = "pipa-nixos";
|
||||
systemd.services.NetworkManager-wait-online.enable = false;
|
||||
|
||||
# Basic environment setup
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
vim
|
||||
htop
|
||||
file
|
||||
];
|
||||
systemd.services."systemd-backlight@backlight:ktz8866-backlight".enable = false;
|
||||
|
||||
networking.localCommands = ''
|
||||
${pkgs.iproute2}/bin/ip addr add 192.168.7.2/24 dev usb0 || true
|
||||
${pkgs.iproute2}/bin/ip link set dev usb0 up || true
|
||||
'';
|
||||
|
||||
systemd.services."serial-getty@ttyGS0" = {
|
||||
enable = true;
|
||||
wantedBy = ["getty.target"];
|
||||
};
|
||||
|
||||
# Basic user profile
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
extraGroups = ["wheel" "networkmanager"];
|
||||
initialPassword = "nixos";
|
||||
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDOwnOKjUpX6gFdSeNkDEETezAhPtHgVfFO0GO44YeD7 roman.lubij@gmail.com"
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings.PermitRootLogin = "no";
|
||||
};
|
||||
|
||||
time.timeZone = "Europe/Prague";
|
||||
|
||||
i18n = {
|
||||
defaultLocale = "en_US.UTF-8";
|
||||
|
||||
extraLocaleSettings = {
|
||||
LC_ADDRESS = "cs_CZ.UTF-8";
|
||||
LC_IDENTIFICATION = "cs_CZ.UTF-8";
|
||||
LC_MEASUREMENT = "cs_CZ.UTF-8";
|
||||
LC_MONETARY = "cs_CZ.UTF-8";
|
||||
LC_NAME = "cs_CZ.UTF-8";
|
||||
LC_NUMERIC = "cs_CZ.UTF-8";
|
||||
LC_PAPER = "cs_CZ.UTF-8";
|
||||
LC_TELEPHONE = "cs_CZ.UTF-8";
|
||||
LC_TIME = "cs_CZ.UTF-8";
|
||||
};
|
||||
};
|
||||
|
||||
console = {
|
||||
keyMap = "cz-lat2";
|
||||
font = "${pkgs.terminus_font}/share/consolefonts/ter-v32n.psf.gz";
|
||||
packages = with pkgs; [terminus_font];
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
usbutils
|
||||
pciutils
|
||||
htop
|
||||
dtc
|
||||
lm_sensors
|
||||
];
|
||||
|
||||
programs.nh = {
|
||||
clean = {
|
||||
enable = true;
|
||||
extraArgs = "--keep-since 7d --keep 10";
|
||||
};
|
||||
enable = true;
|
||||
flake = "/home/nixos/.config/nixos";
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
nix.settings = {
|
||||
auto-optimise-store = true;
|
||||
experimental-features = [
|
||||
"flakes"
|
||||
"nix-command"
|
||||
];
|
||||
|
||||
warn-dirty = false;
|
||||
};
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Generated
+7
-21
@@ -2,37 +2,23 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1764521362,
|
||||
"narHash": "sha256-M101xMtWdF1eSD0xhiR8nG8CXRlHmv6V+VoY65Smwf4=",
|
||||
"owner": "nixos",
|
||||
"lastModified": 1779102034,
|
||||
"narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "871b9fd269ff6246794583ce4ee1031e1da71895",
|
||||
"rev": "687f05a9184cad4eaf905c48b63649e3a86f5433",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "25.11",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-25.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pipa-kernel-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1766599765,
|
||||
"narHash": "sha256-ApsnYs38vrKwEbvO0d0c4aqpCRQe5FQ7Aa66U38x8JI=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/pipa-mainline/linux/archive/576f7cb3848179b36ef92420a1ab4c910b53b357.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/pipa-mainline/linux/archive/576f7cb3848179b36ef92420a1ab4c910b53b357.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pipa-kernel-src": "pipa-kernel-src"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,28 +1,119 @@
|
||||
{
|
||||
description = "NixOS for Xiaomi Pad 6 (pipa)";
|
||||
description = "Xiaomi Pad 6 (pipa) NixOS Flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/25.11";
|
||||
|
||||
# The exact working 6.18.2 vendor source tree from your spec file
|
||||
pipa-kernel-src = {
|
||||
url = "https://github.com/pipa-mainline/linux/archive/576f7cb3848179b36ef92420a1ab4c910b53b357.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
pipa-kernel-src,
|
||||
...
|
||||
} @ inputs: {
|
||||
} @ inputs: let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
toplevel = self.nixosConfigurations.pipa.config.system.build.toplevel;
|
||||
|
||||
buildImagesScript = pkgs.writeShellScriptBin "build-pipa-images" ''
|
||||
set -e
|
||||
MNT_DIR="$PWD/mnt"
|
||||
OUT_DIR="$PWD/images"
|
||||
|
||||
echo "=> Creating output directories..."
|
||||
mkdir -p "$OUT_DIR"
|
||||
mkdir -p "$MNT_DIR"
|
||||
|
||||
# SAFETY NET: Automatically unmount if the script fails or is cancelled
|
||||
cleanup() {
|
||||
echo "=> Ensuring mounts are released..."
|
||||
sync
|
||||
sudo umount "$MNT_DIR/boot" 2>/dev/null || true
|
||||
sudo umount "$MNT_DIR/nix" 2>/dev/null || true
|
||||
sudo umount "$MNT_DIR/home" 2>/dev/null || true
|
||||
sudo umount "$MNT_DIR" 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "=> Wiping old images..."
|
||||
rm -f "$OUT_DIR/boot.img" "$OUT_DIR/rootfs.img" "$OUT_DIR/rootfs.sparse.img"
|
||||
|
||||
echo "=> Instantly preallocating blocks via fallocate (1GB Boot, 4GB RootFS)..."
|
||||
${pkgs.util-linux}/bin/fallocate -l 1G "$OUT_DIR/boot.img"
|
||||
${pkgs.util-linux}/bin/fallocate -l 4G "$OUT_DIR/rootfs.img"
|
||||
|
||||
echo "=> Formatting images natively..."
|
||||
${pkgs.dosfstools}/bin/mkfs.vfat -S 4096 -F 32 -n NIX_BOOT "$OUT_DIR/boot.img"
|
||||
${pkgs.btrfs-progs}/bin/mkfs.btrfs --sectorsize 4096 -L NIX_ROOT "$OUT_DIR/rootfs.img" -f
|
||||
|
||||
echo "=> Creating Btrfs subvolumes..."
|
||||
sudo mount -t btrfs "$OUT_DIR/rootfs.img" "$MNT_DIR"
|
||||
sudo btrfs subvolume create "$MNT_DIR/root"
|
||||
sudo btrfs subvolume create "$MNT_DIR/nix"
|
||||
sudo btrfs subvolume create "$MNT_DIR/home"
|
||||
sudo umount "$MNT_DIR"
|
||||
|
||||
echo "=> Mounting images in Btrfs sequence..."
|
||||
sudo mount -o subvol=root "$OUT_DIR/rootfs.img" "$MNT_DIR"
|
||||
|
||||
sudo mkdir -p "$MNT_DIR/boot" "$MNT_DIR/nix" "$MNT_DIR/home"
|
||||
|
||||
sudo mount -o subvol=nix "$OUT_DIR/rootfs.img" "$MNT_DIR/nix"
|
||||
sudo mount -o subvol=home "$OUT_DIR/rootfs.img" "$MNT_DIR/home"
|
||||
sudo mount "$OUT_DIR/boot.img" "$MNT_DIR/boot"
|
||||
|
||||
echo "=> Seeding NixOS configuration into the user's home folder..."
|
||||
TARGET_FLAKE_DIR="$MNT_DIR/home/nixos/.config/nixos"
|
||||
sudo mkdir -p "$TARGET_FLAKE_DIR"
|
||||
|
||||
sudo cp flake.nix configuration.nix hardware-configuration.nix "$TARGET_FLAKE_DIR/"
|
||||
sudo cp -r pkgs "$TARGET_FLAKE_DIR/"
|
||||
|
||||
if [ -d "firmware" ]; then
|
||||
sudo cp -r firmware "$TARGET_FLAKE_DIR/"
|
||||
fi
|
||||
|
||||
echo "=> Securing permissions and initializing Git repo..."
|
||||
sudo chown -R 1000:100 "$MNT_DIR/home/nixos"
|
||||
|
||||
sudo git -C "$TARGET_FLAKE_DIR" init
|
||||
sudo git -C "$TARGET_FLAKE_DIR" add .
|
||||
|
||||
echo "=> Injecting the ARM64 OS and native Bootloader..."
|
||||
sudo SYSTEMD_RELAX_ESP_CHECKS=1 ${pkgs.nixos-install}/bin/nixos-install \
|
||||
--root "$MNT_DIR" \
|
||||
--system "${toplevel}" \
|
||||
--no-root-passwd \
|
||||
--no-channel-copy
|
||||
|
||||
echo "=> Flushing write caches and unmounting cleanly..."
|
||||
cleanup
|
||||
trap - EXIT
|
||||
|
||||
echo "=> Converting RootFS to Android sparse format..."
|
||||
${pkgs.android-tools}/bin/img2simg "$OUT_DIR/rootfs.img" "$OUT_DIR/rootfs.sparse.img"
|
||||
|
||||
echo "✅ Done! 'boot.img' (raw) and 'rootfs.sparse.img' are ready for fastboot."
|
||||
'';
|
||||
in {
|
||||
nixosConfigurations.pipa = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
|
||||
specialArgs = {
|
||||
pkgsCross = import nixpkgs {
|
||||
localSystem = "x86_64-linux";
|
||||
crossSystem = "aarch64-linux";
|
||||
};
|
||||
};
|
||||
|
||||
modules = [
|
||||
./hardware-configuration.nix
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
specialArgs = {inherit inputs;};
|
||||
};
|
||||
|
||||
apps."x86_64-linux".default = {
|
||||
type = "app";
|
||||
program = "${buildImagesScript}/bin/build-pipa-images";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
+88
-45
@@ -1,57 +1,100 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
pkgsCross ? null,
|
||||
...
|
||||
}: {
|
||||
boot.kernelPackages = let
|
||||
# 1. Patch the vendor code natively (Fast, zero QEMU)
|
||||
patchedSrc = pkgs.buildPackages.runCommand "pipa-kernel-src-patched" {} ''
|
||||
cp -r ${inputs.pipa-kernel-src} $out
|
||||
chmod -R +w $out
|
||||
}: let
|
||||
kernelPkgs =
|
||||
if pkgsCross != null
|
||||
then pkgsCross
|
||||
else pkgs;
|
||||
|
||||
# Fix keyboard driver headers
|
||||
sed -i '1i #include <linux/gpio/consumer.h>' $out/drivers/input/keyboard/nanosic_803.c
|
||||
sed -i '1i #include <linux/hex.h>' $out/drivers/input/keyboard/nanosic_803.c
|
||||
pipa-firmware = pkgs.callPackage ./pkgs/firmware.nix {};
|
||||
pipa-kernel = kernelPkgs.callPackage ./pkgs/kernel.nix {};
|
||||
in {
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
# Fix charger driver dead SIMD header
|
||||
sed -i 's|#include <asm/neon.h>|/* #include <asm/neon.h> safely removed */|' $out/drivers/power/supply/bq25970_charger.c
|
||||
|
||||
# Fix touchscreen driver MediaTek artifact (Deletes lines 1243 and 1244)
|
||||
sed -i '1243,1244d' $out/drivers/input/touchscreen/nt36523/nt36xxx.c
|
||||
'';
|
||||
|
||||
# 2. Cross-compile using the patched source
|
||||
customKernel = pkgs.buildLinux {
|
||||
version = "6.18.2-pipa";
|
||||
modDirVersion = "6.18.2";
|
||||
|
||||
src = patchedSrc;
|
||||
configfile = ./pipa.config;
|
||||
dtbTarget = "qcom/sm8250-xiaomi-pipa.dtb";
|
||||
ignoreConfigErrors = true;
|
||||
|
||||
structuredExtraConfig = with lib.kernel; {
|
||||
FW_LOADER = lib.mkForce yes;
|
||||
RUST = lib.mkForce no;
|
||||
DRM_NOVA = lib.mkForce no;
|
||||
};
|
||||
boot = {
|
||||
loader = {
|
||||
systemd-boot.enable = true;
|
||||
efi.canTouchEfiVariables = false;
|
||||
};
|
||||
in
|
||||
lib.recurseIntoAttrs (pkgs.linuxPackagesFor customKernel);
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Native cross-compilation speeds (x86_64 -> ARM64)
|
||||
# -------------------------------------------------------------------
|
||||
nixpkgs.buildPlatform = "x86_64-linux";
|
||||
nixpkgs.hostPlatform = "aarch64-linux";
|
||||
kernelPackages = kernelPkgs.linuxPackagesFor pipa-kernel;
|
||||
|
||||
boot.loader.grub.enable = false;
|
||||
boot.loader.generic-extlinux-compatible.enable = true;
|
||||
initrd = {
|
||||
availableKernelModules = [
|
||||
"panel_novatek_nt36532"
|
||||
"msm"
|
||||
"nanosic_803"
|
||||
"usbhid"
|
||||
"pinctrl_sm8250"
|
||||
];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/root";
|
||||
fsType = "ext4";
|
||||
kernelModules = [
|
||||
];
|
||||
};
|
||||
|
||||
kernelParams = [
|
||||
"console=tty0"
|
||||
"console=ttyGS0"
|
||||
"pd_ignore_unused"
|
||||
"clk_ignore_unused"
|
||||
"fbcon=rotate:1"
|
||||
];
|
||||
|
||||
kernelModules = ["g_ether"];
|
||||
extraModulePackages = [];
|
||||
|
||||
growPartition = true;
|
||||
};
|
||||
|
||||
hardware = {
|
||||
firmware = [
|
||||
pipa-firmware
|
||||
pkgs.linux-firmware
|
||||
];
|
||||
|
||||
graphics = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
enableRedistributableFirmware = lib.mkDefault true;
|
||||
deviceTree.name = "qcom/sm8250-xiaomi-pipa.dtb";
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-label/NIX_BOOT";
|
||||
fsType = "vfat";
|
||||
options = ["fmask=0022" "dmask=0022"];
|
||||
};
|
||||
|
||||
"/" = {
|
||||
device = "/dev/disk/by-label/NIX_ROOT";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=root" "compress=zstd" "noatime"];
|
||||
};
|
||||
|
||||
"/nix" = {
|
||||
device = "/dev/disk/by-label/NIX_ROOT";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=nix" "compress=zstd" "noatime"];
|
||||
neededForBoot = true;
|
||||
};
|
||||
|
||||
"/home" = {
|
||||
device = "/dev/disk/by-label/NIX_ROOT";
|
||||
fsType = "btrfs";
|
||||
options = ["subvol=home" "compress=zstd" "noatime"];
|
||||
};
|
||||
};
|
||||
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "schedutil";
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
stdenvNoCC,
|
||||
fetchFromGitea,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "xiaomi-pipa-firmware";
|
||||
version = "1.1-2";
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "gitea.awroo.fun";
|
||||
owner = "romanl";
|
||||
repo = "xiaomi-pipa-firmware";
|
||||
rev = "842d35beffeda8c6d1b0e611b335543bf0e6b41e";
|
||||
hash = "sha256-NPApyQVkcDXcxNh1AK863r6VQGP4VQMapoFgHYni8fA=";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# 1. Standard Firmware (awinic, novatek)
|
||||
# These live natively in lib/firmware/ in the source repo
|
||||
mkdir -p $out/lib/firmware
|
||||
cp -a lib/firmware/awinic $out/lib/firmware/
|
||||
cp -a lib/firmware/novatek $out/lib/firmware/
|
||||
|
||||
# Catch nuvolta just in case, as it appeared in your .files output
|
||||
if [ -d "lib/firmware/nuvolta" ]; then
|
||||
cp -a lib/firmware/nuvolta $out/lib/firmware/
|
||||
fi
|
||||
|
||||
# 2. Qualcomm SoC Firmware (.mbn / .jsn)
|
||||
# The Fedora spec explicitly shifts these into a 'qcom' subdirectory
|
||||
mkdir -p $out/lib/firmware/qcom
|
||||
cp -a lib/firmware/sm8250 $out/lib/firmware/qcom/
|
||||
|
||||
# 3. DSP, Sensors, and Userspace Configs
|
||||
# These live in usr/share/ in the source repo. In Nix, package data goes to $out/share
|
||||
mkdir -p $out/share
|
||||
cp -a usr/share/qcom $out/share/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
lib,
|
||||
buildLinux,
|
||||
fetchFromGitea,
|
||||
runCommand,
|
||||
...
|
||||
} @ args: let
|
||||
# 1. Fetch the raw source
|
||||
rawSrc = fetchFromGitea {
|
||||
domain = "gitea.awroo.fun";
|
||||
owner = "romanl";
|
||||
repo = "linux";
|
||||
rev = "576f7cb3848179b36ef92420a1ab4c910b53b357";
|
||||
hash = "sha256-ApsnYs38vrKwEbvO0d0c4aqpCRQe5FQ7Aa66U38x8JI=";
|
||||
};
|
||||
|
||||
# 2. Create a modified source tree with pipa.config pre-injected
|
||||
patchedSrc = runCommand "linux-src-pipa" {} ''
|
||||
cp -a ${rawSrc} $out
|
||||
chmod -R +w $out
|
||||
cp ${./pipa.config} $out/arch/arm64/configs/pipa.config
|
||||
'';
|
||||
in
|
||||
buildLinux (args
|
||||
// {
|
||||
version = "6.18.2";
|
||||
modDirVersion = "6.18.2";
|
||||
|
||||
src = patchedSrc;
|
||||
|
||||
defconfig = "defconfig pipa.config";
|
||||
|
||||
ignoreConfigErrors = true;
|
||||
extraMeta.branch = "6.18";
|
||||
})
|
||||
@@ -4826,7 +4826,7 @@ CONFIG_DRM_KOMEDA=m
|
||||
# CONFIG_DRM_QXL is not set
|
||||
CONFIG_DRM_VIRTIO_GPU=y
|
||||
CONFIG_DRM_VIRTIO_GPU_KMS=y
|
||||
CONFIG_DRM_MSM=y
|
||||
CONFIG_DRM_MSM=m
|
||||
CONFIG_DRM_MSM_GPU_STATE=y
|
||||
CONFIG_DRM_MSM_MDSS=y
|
||||
CONFIG_DRM_MSM_MDP4=y
|
||||
Reference in New Issue
Block a user