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

40 lines
995 B
Ruby
Raw Normal View History

2019-12-22 07:12:39 +03:00
# TODO: Allow defining depending on stage-0/stage-1.
STAGE = 1
2019-12-23 06:32:34 +03:00
FAILURE_SLEEP = 10
$configuration = JSON.parse(File.read("/etc/boot/config"));
2019-12-22 07:12:39 +03:00
log("************************")
log("* Mobile NixOS stage-#{STAGE} *")
log("************************")
log("")
log("Built for device #{$configuration["device"]["name"]}")
2019-12-22 07:12:39 +03:00
log("")
2019-12-21 08:38:27 +03:00
2019-12-23 06:32:34 +03:00
Tasks::Splash.new("stage-0")
Tasks::Symlink.new("/proc/mounts", "/etc/mtab")
Tasks::Mount.new("/dev/pts", type: "devpts")
.add_dependency(:Files, "/dev/")
Tasks::Mount.new("/dev", type: "devtmpfs")
Tasks::Mount.new("/proc", type: "proc")
Tasks::Mount.new("/sys", type: "sysfs")
[
"/run",
"/etc/udev",
"/var/log",
].each do |dir|
Tasks::Directory.new(dir)
2019-12-21 08:38:27 +03:00
end
2019-12-23 06:32:34 +03:00
Tasks::Splash.new("stage-1")
2019-12-23 07:26:46 +03:00
.add_dependency(:SingletonTask, :UDev)
2019-12-21 08:38:27 +03:00
Tasks::Mount.new($configuration["root"]["device"], "/mnt")
2019-12-21 08:38:27 +03:00
2019-12-23 06:32:34 +03:00
Tasks::go()
2019-12-21 08:38:27 +03:00
2019-12-23 06:32:34 +03:00
$logger.fatal("Tasks all ran, but we're still here...")
$logger.fatal("Sleeping for #{FAILURE_SLEEP} seconds then exiting...")
sleep(FAILURE_SLEEP)
exit(99)