1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-16 11:43:21 +03:00

demo: Enable adbd in burn tool

This commit is contained in:
Samuel Dionne-Riel 2020-01-13 19:53:27 -05:00
parent 0815a83dcf
commit c15460b6d4

View File

@ -7,39 +7,40 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (lib) mkMerge mkOrder; device_info = config.mobile.device.info;
in in
{ {
config = mkMerge [ # Ensures we don't quit stage-1
{ mobile.boot.stage-1.shell.enable = true;
# Ensures we don't quit stage-1 # Only enable `adb` if we know how to.
mobile.boot.stage-1.shell.enable = true; # FIXME: relies on implementation details. Poor separation of concerns.
mobile.adbd.enable = (config.mobile.system.type == "android") &&
(config.mobile.usb.mode != "gadgetfs" || device_info.gadgetfs.functions ? ffs)
;
# Enables networking and ssh in stage-1 ! # Enables networking and ssh in stage-1 !
mobile.boot.stage-1.networking.enable = true; mobile.boot.stage-1.networking.enable = true;
mobile.boot.stage-1.ssh.enable = true; mobile.boot.stage-1.ssh.enable = true;
mobile.boot.stage-1.fbterm.enable = true; mobile.boot.stage-1.fbterm.enable = true;
mobile.boot.stage-1.tasks = [ mobile.boot.stage-1.tasks = [
(pkgs.writeText "adjust-brightness-task.rb" '' (pkgs.writeText "adjust-brightness-task.rb" ''
class Tasks::AdjustBrightness < SingletonTask class Tasks::AdjustBrightness < SingletonTask
def initialize() def initialize()
add_dependency(:Target, :Environment) add_dependency(:Target, :Environment)
add_dependency(:Target, :Graphics) add_dependency(:Target, :Graphics)
end end
def run() def run()
["lcd-backlight", "wled"].each do |file| ["lcd-backlight", "wled"].each do |file|
# This can fail to write, ignore... # This can fail to write, ignore...
begin begin
max = File.read("/sys/class/leds/#{file}/max_brightness").to_i max = File.read("/sys/class/leds/#{file}/max_brightness").to_i
File.write("/sys/class/leds/#{file}/brightness", (max * 0.1).to_i) File.write("/sys/class/leds/#{file}/brightness", (max * 0.1).to_i)
rescue rescue
end
end
end end
end end
'') end
]; end
} '')
]; ];
} }