diff --git a/examples/testing/crash-before-switch-root/README.md b/examples/testing/crash-before-switch-root/README.md new file mode 100644 index 00000000..63e92634 --- /dev/null +++ b/examples/testing/crash-before-switch-root/README.md @@ -0,0 +1,38 @@ +`crash-before-switch-root` +========================== + +What does this test? +-------------------- + +A simple known method to crash the system at boot. + +This can be used to check changes to the errors handling. + + +Why is this scary? +------------------ + +Not scary at all. Only pretty useless in daily use! + + +How is success defined? +----------------------- + +The boot process should proceed normally (splash, etc), but be +interrupted before switch root. + +The crashing happens *after* mounting /mnt, but *before* switching root. + + +Running +------- + +Assuming you are `cd`'d into the root of a Mobile NixOS checkout: + +``` +nix-build ./examples/testing/crash-before-switch-root && ./result +``` + +This will build for qemu-x86_64 by default. + +As always, be mindful of your `NIX_PATH`. diff --git a/examples/testing/crash-before-switch-root/configuration.nix b/examples/testing/crash-before-switch-root/configuration.nix new file mode 100644 index 00000000..b3170dd2 --- /dev/null +++ b/examples/testing/crash-before-switch-root/configuration.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, ... }: + +{ + mobile.boot.stage-1.tasks = [ ./crash.rb ]; + + mobile.boot.stage-1.bootConfig = { + log.level = lib.mkForce "INFO"; + }; +} diff --git a/examples/testing/crash-before-switch-root/crash.rb b/examples/testing/crash-before-switch-root/crash.rb new file mode 100644 index 00000000..0c6e1f62 --- /dev/null +++ b/examples/testing/crash-before-switch-root/crash.rb @@ -0,0 +1,12 @@ +class Tasks::Crash < SingletonTask + def initialize() + # Runs before SwitchRoot + Targets[:SwitchRoot].add_dependency(:Task, self) + # And after /mnt is available + add_dependency(:Mount, "/mnt") + end + + def run() + raise "This is an exception from init!" + end +end diff --git a/examples/testing/crash-before-switch-root/default.nix b/examples/testing/crash-before-switch-root/default.nix new file mode 100644 index 00000000..00840c78 --- /dev/null +++ b/examples/testing/crash-before-switch-root/default.nix @@ -0,0 +1,11 @@ +{ device ? "qemu-x86_64" }: +let + system-build = import ../../../. { + inherit device; + configuration = [ { imports = [ + ../../hello/configuration.nix + ./configuration.nix + ]; } ]; + }; +in + system-build.build.default