1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 19:23:01 +03:00

examples/demo: Use eval-with-configuration.nix

In addition, drop `android-burn-tool`. It hasn't been used for while, as
in the end it is not actually needed.
This commit is contained in:
Samuel Dionne-Riel 2021-02-21 17:31:49 -05:00
parent f1268082f9
commit 0ef6bd9d5d
3 changed files with 19 additions and 92 deletions

View File

@ -1,5 +1,7 @@
> **WARNING**: This is still highly experimental. This is not usable as a daily
> driver.
> **WARNING**: This is not usable as a daily driver.
This system is meant as *something* that is usable (barely) on mobile devices,
while waiting for a more proper phone environment to be packaged.
## Building
@ -8,29 +10,12 @@ armv7, aarch64 on aarch64).
(Though the tooling will try to build it through cross-compilation!)
> Note that this has been verified to work on `asus-z00t` on September 24th 2019,
> using nixpkgs commit `d484f2b7fc0834a068e8ace851faa449a03963f5`.
It should be possible to build both boot images via cross-compilation.
## Burning
To burn the image, build the android-burn-tool, then fastboot it.
This will differ depending on the device.
```
nix-build examples/demo/ --argstr device asus-flo -A android-burn-tool
fastboot boot result
```
Once booting, it will show a yellow screen, then either a red or a green screen.
The green screen means that it has found the expected partition to flash. A red
screen means that the user will need to check what is up.
The command will look like:
```
dd if=system.img bs=2M status=progress | bin/ssh-initrd dd of=/dev/[...] bs=2M
```
A common issue with android-based devices is the `system` partition being too
small. To work around this issue, flash to `userdata`.
## Booting
@ -41,4 +26,4 @@ The `boot.img` boot image is expecting to find the system partition using its
label.
It should also be possible to do this entirely statelessly by burning to an SD
card, and fastboot booting the device.
card, and using `fastboot boot`.

View File

@ -1,46 +0,0 @@
# This is intended to be used to produce a bootable `boot.img` with adbd, and
# dropbear enabled. You would, in turn, use it to "flash" a dumb system.img file
# to a partition, like userdata.
#
# *CAUTION* : there is no protection against flashing over the wrong partition.
# Read about the usual pitfalls in the Android section of the documentation.
{ config, lib, pkgs, ... }:
let
device_info = config.mobile.device.info;
in
{
# Ensures we don't quit stage-1
mobile.boot.stage-1.shell.enable = true;
# Only enable `adb` if we know how to.
# FIXME: relies on implementation details. Poor separation of concerns.
mobile.adbd.enable = (config.mobile.system.type == "android") &&
(config.mobile.usb.mode != "gadgetfs" || config.mobile.usb.gadgetfs.functions ? ffs)
;
# Enables networking and ssh in stage-1 !
mobile.boot.stage-1.networking.enable = true;
mobile.boot.stage-1.ssh.enable = true;
mobile.boot.stage-1.fbterm.enable = true;
mobile.boot.stage-1.tasks = [
(pkgs.writeText "adjust-brightness-task.rb" ''
class Tasks::AdjustBrightness < SingletonTask
def initialize()
add_dependency(:Target, :Environment)
add_dependency(:Target, :Graphics)
end
def run()
["lcd-backlight", "wled"].each do |file|
# This can fail to write, ignore...
begin
max = File.read("/sys/class/leds/#{file}/max_brightness").to_i
System.write("/sys/class/leds/#{file}/brightness", (max * 0.1).to_i)
rescue
end
end
end
end
'')
];
}

View File

@ -1,23 +1,11 @@
{ device ? null }:
let
system-build = import ../../. {
inherit device;
configuration = [ { imports = [ ./configuration.nix ]; } ];
};
burn-tool-build = import ../../. {
inherit device;
configuration = [ { imports = [ ./android-burn-tool.nix ]; } ];
};
in
{
inherit (system-build) build;
inherit (system-build.build)
# Android devices
android-bootimg android-device
# QEMU VM
vm
# Depthcharge
disk-image
;
android-burn-tool = burn-tool-build.build.android-bootimg;
}
{ device ? null, pkgs ? null }@args:
import ../../lib/eval-with-configuration.nix (args // {
configuration = [ (import ./configuration.nix) ];
additionalHelpInstructions = ''
You can build the `-A build.default` attribute to build the default output
for your device.
$ nix-build examples/demo --argstr device ${device} -A build.default
'';
})