1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 11:03:37 +03:00
mobile-nixos/modules/initrd-loop.nix
2020-02-03 16:19:10 -05:00

44 lines
1.0 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.mobile.boot.stage-1.loop-forever;
in
{
options.mobile.boot.stage-1.loop-forever = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Enables loop-forever.
This will "freeze" the initrd, no switch root will happen.
Enabling additional services (like `ssh`) will allow inspecting
the stage-1 phase.
'';
};
};
config.mobile.boot.stage-1 = lib.mkIf cfg.enable {
tasks = [
(pkgs.writeText "loop-task.rb" ''
class Tasks::LoopForever < SingletonTask
def initialize()
# Wedge the task between the target "root", and the
# actual task we want to prevent running.
add_dependency(:Target, :SwitchRoot)
SwitchRoot.instance.add_dependency(:Task, self)
end
def run()
puts("\nLooping forever.\n")
loop do
sleep 3600
end
end
end
'')
];
};
}