Compare commits
2 Commits
70bbdd253a
...
d511a82b0c
Author | SHA1 | Date | |
---|---|---|---|
d511a82b0c | |||
5d7cec46e9 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
||||||
/flashing/
|
/flashing/
|
||||||
/debug/
|
/debug/
|
||||||
/tools/
|
/tools/
|
||||||
|
/.cache/
|
||||||
|
|
|
@ -4,13 +4,78 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default =
|
||||||
packages = with pkgs; [
|
let
|
||||||
android-tools
|
lineageBuildZipUrl = "https://mirrorbits.lineageos.org/full/a71/20241225/lineage-21.0-20241225-nightly-a71-signed.zip";
|
||||||
(python3.withPackages (pypi: with pypi; [
|
lineageBuildZip = pkgs.fetchurl {
|
||||||
libfdt
|
url = lineageBuildZipUrl;
|
||||||
]))
|
hash = "sha256-G+ibXe1crfhFnB2sfSKtI4XDx1qysMj75H7aTJcUUm0=";
|
||||||
];
|
};
|
||||||
};
|
lineageBuildZipContent = pkgs.fetchzip {
|
||||||
|
url = lineageBuildZipUrl;
|
||||||
|
hash = "sha256-nBn26btXmW5u1oYCqucAbk6ixzMxGNapuMofBisv56o=";
|
||||||
|
stripRoot = false;
|
||||||
|
};
|
||||||
|
magiskApk = pkgs.fetchurl {
|
||||||
|
url = "https://github.com/topjohnwu/Magisk/releases/download/v28.1/Magisk-v28.1.apk";
|
||||||
|
hash = "sha256-i/0zRrPaWBT4Lv9vGxtf7dCtWF85olcJsj61SqxFaR0=";
|
||||||
|
};
|
||||||
|
emptyDtbo = pkgs.runCommand "empty-dtbo" {} ''
|
||||||
|
mkdir $out
|
||||||
|
dd if=/dev/zero of=$out/empty_dtbo.img count=1
|
||||||
|
${pkgs.android-tools}/bin/avbtool add_hash_footer --partition_name dtbo --partition_size 2621440 --image $out/empty_dtbo.img
|
||||||
|
'';
|
||||||
|
# rootDir = builtins.toString ./..;
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
(python3.withPackages (pypi: with pypi; [
|
||||||
|
libfdt
|
||||||
|
]))
|
||||||
|
(writeShellScriptBin "flash-lineage-magisk" ''
|
||||||
|
rootDir="." # Assume PWD as root for now
|
||||||
|
lineageBootImg="$rootDir/.cache/lineageos-magisk-boot.img"
|
||||||
|
|
||||||
|
if [[ ! -e "$lineageBootImg" ]]; then
|
||||||
|
echo "Wait for Android to have fully booted and ensure USB debugging is enabled."
|
||||||
|
read -p "Press enter to continue..."
|
||||||
|
|
||||||
|
mkdir -p "$rootDir/.cache"
|
||||||
|
installedMagisk=$(adb shell pm list packages com.topjohnwu.magisk)
|
||||||
|
if [[ -z "$installedMagisk" ]]; then
|
||||||
|
echo "Magisk not found on device. Installing now..."
|
||||||
|
adb sideload "${magiskApk}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
adb push "${lineageBuildZipContent}/boot.img" "/storage/emulated/0/Download/lineageos-boot.img"
|
||||||
|
echo "Launching Magisk. Patch the boot image located in the downloads directory."
|
||||||
|
adb shell monkey -p com.topjohnwu.magisk 1
|
||||||
|
read -p "Press enter to continue..."
|
||||||
|
|
||||||
|
adb shell 'cp /storage/emulated/0/Download/magisk_patched*.img /storage/emulated/0/Download/magisk-boot.img'
|
||||||
|
sleep 1
|
||||||
|
adb shell 'rm /storage/emulated/0/Download/magisk_patched*.img'
|
||||||
|
adb pull "/storage/emulated/0/Download/magisk-boot.img" "$lineageBootImg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Boot into download mode."
|
||||||
|
read -p "Press enter to continue..."
|
||||||
|
heimdall flash --BOOT "$lineageBootImg"
|
||||||
|
'')
|
||||||
|
(writeShellScriptBin "flash-lineage" ''
|
||||||
|
echo "Installing LineageOS..."
|
||||||
|
adb sideload ${lineageBuildZip}
|
||||||
|
|
||||||
|
flash-lineage-magisk
|
||||||
|
'')
|
||||||
|
(writeShellScriptBin "flash-postmarketos" ''
|
||||||
|
echo "Installing postmarketOS..."
|
||||||
|
heimdall flash \
|
||||||
|
--no-reboot \
|
||||||
|
--DTBO ${emptyDtbo}/empty_dtbo.img
|
||||||
|
pmbootstrap flasher --method heimdall-bootimg --resume flash_kernel
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
12
flake.lock
12
flake.lock
|
@ -20,16 +20,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733759999,
|
"lastModified": 1734991663,
|
||||||
"narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
|
"narHash": "sha256-8T660guvdaOD+2/Cj970bWlQwAyZLKrrbkhYOFcY1YE=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
|
"rev": "6c90912761c43e22b6fb000025ab96dd31c971ff",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixos-24.11",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
description = "A very basic flake";
|
description = "A very basic flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user