mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-15 19:23:01 +03:00
initrd: Implement shell with a task
This commit is contained in:
parent
62b7b47117
commit
56cdb1abca
@ -1,7 +1,6 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
with import ./initrd-order.nix;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.mobile.boot.stage-1.shell;
|
cfg = config.mobile.boot.stage-1.shell;
|
||||||
@ -29,12 +28,25 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.mobile.boot.stage-1 = {
|
config.mobile.boot.stage-1 = lib.mkIf cfg.enable {
|
||||||
init = lib.mkIf cfg.enable (lib.mkOrder BEFORE_SWITCH_ROOT_INIT ''
|
tasks = [
|
||||||
echo
|
(pkgs.writeText "run-shell-task.rb" ''
|
||||||
echo "Exit this shell (CTRL+D) to resume booting."
|
class Tasks::RunShell < SingletonTask
|
||||||
echo
|
def initialize()
|
||||||
setsid /bin/sh -c /bin/sh < /dev/${cfg.console} >/dev/${cfg.console} 2>/dev/${cfg.console}
|
# 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()
|
||||||
|
cmd = %q{setsid /bin/sh -c /bin/sh < /dev/${cfg.console} >/dev/${cfg.console} 2>/dev/${cfg.console}}
|
||||||
|
$logger.debug(" $ #{cmd}")
|
||||||
|
puts("\nExit this shell (CTRL+D) to resume booting.\n")
|
||||||
|
system(cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user