mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-01 03:32:26 +03:00
Use mkMerge
to merge multiple configs.
This commit is contained in:
parent
0a1b75d91c
commit
86157753f8
@ -1,27 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
with import ./initrd-order.nix;
|
||||
|
||||
let
|
||||
cfg = config.mobile.boot.stage-1.redirect-log;
|
||||
|
||||
# Used in the script
|
||||
logger_run = "/run/initrd";
|
||||
pidfile = "${logger_run}/init.log.pid";
|
||||
in
|
||||
{
|
||||
config.mobile.boot.stage-1 = {
|
||||
# FIXME : this may not cleanup nicely.
|
||||
# This implementation is naive and simple.
|
||||
init = lib.mkIf cfg.enable (lib.mkOrder AFTER_SWITCH_ROOT_INIT ''
|
||||
_stop_logger() {
|
||||
local i=0 pid
|
||||
# re-attach to /dev/console
|
||||
exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
|
||||
# Kill the process
|
||||
kill $(cat ${pidfile})
|
||||
}
|
||||
'');
|
||||
};
|
||||
}
|
@ -36,43 +36,58 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config.mobile.boot.stage-1 = {
|
||||
redirect-log.targets = [
|
||||
# Always redirects (tautologically) to /dev/console at least.
|
||||
"/dev/console"
|
||||
]
|
||||
++ optional cfg.enable "/init.log"
|
||||
;
|
||||
config.mobile.boot.stage-1 = mkMerge [
|
||||
{
|
||||
redirect-log.targets = [
|
||||
# Always redirects (tautologically) to /dev/console at least.
|
||||
"/dev/console"
|
||||
]
|
||||
++ optional cfg.enable "/init.log"
|
||||
;
|
||||
|
||||
# FIXME : this may not cleanup nicely.
|
||||
# This implementation is naive and simple.
|
||||
init = lib.mkIf cfg.enable (lib.mkOrder AFTER_DEVICE_INIT ''
|
||||
_logger() {
|
||||
# Setup all redirections
|
||||
${builtins.concatStringsSep "\n" (
|
||||
imap0 (i: t: ''
|
||||
exec ${toString(i+fd_base)}>${t} 2>&1
|
||||
'') cfg.targets
|
||||
)}
|
||||
# FIXME : this may not cleanup nicely.
|
||||
# This implementation is naive and simple.
|
||||
init = lib.mkIf cfg.enable (lib.mkOrder AFTER_DEVICE_INIT ''
|
||||
_logger() {
|
||||
# Setup all redirections
|
||||
${builtins.concatStringsSep "\n" (
|
||||
imap0 (i: t: ''
|
||||
exec ${toString(i+fd_base)}>${t} 2>&1
|
||||
'') cfg.targets
|
||||
)}
|
||||
|
||||
# Continuously read from pipe
|
||||
while read -r line; do
|
||||
${builtins.concatStringsSep "\n" (
|
||||
imap0 (i: t: ''
|
||||
printf '%s\n' "$line" >&${toString(i+fd_base)}
|
||||
'') cfg.targets
|
||||
)}
|
||||
done
|
||||
|
||||
# Cleanup behind ourselves
|
||||
rm -f ${pipe} ${pidfile}
|
||||
}
|
||||
# Continuously read from pipe
|
||||
while read -r line; do
|
||||
${builtins.concatStringsSep "\n" (
|
||||
imap0 (i: t: ''
|
||||
printf '%s\n' "$line" >&${toString(i+fd_base)}
|
||||
'') cfg.targets
|
||||
)}
|
||||
done
|
||||
|
||||
# Cleanup behind ourselves
|
||||
rm -f ${pipe} ${pidfile}
|
||||
}
|
||||
|
||||
mkdir -p ${logger_run}
|
||||
mkfifo ${pipe}
|
||||
_logger < ${pipe} > /dev/console 2&1 &
|
||||
printf %s $! > ${pidfile}
|
||||
exec >${pipe} 2>&1
|
||||
'');
|
||||
};
|
||||
mkdir -p ${logger_run}
|
||||
mkfifo ${pipe}
|
||||
_logger < ${pipe} > /dev/console 2&1 &
|
||||
printf %s $! > ${pidfile}
|
||||
exec >${pipe} 2>&1
|
||||
'');
|
||||
}
|
||||
{
|
||||
# FIXME : this may not cleanup nicely.
|
||||
# This implementation is naive and simple.
|
||||
init = lib.mkIf cfg.enable (lib.mkOrder AFTER_SWITCH_ROOT_INIT ''
|
||||
_stop_logger() {
|
||||
local i=0 pid
|
||||
# re-attach to /dev/console
|
||||
exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
|
||||
# Kill the process
|
||||
kill $(cat ${pidfile})
|
||||
}
|
||||
'');
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
with import ./initrd-order.nix;
|
||||
|
||||
let
|
||||
cfg = config.mobile.boot.stage-1.splash;
|
||||
in
|
||||
{
|
||||
config.mobile.boot.stage-1 = lib.mkIf cfg.enable {
|
||||
init = lib.mkOrder READY_INIT ''
|
||||
show_splash splash
|
||||
'';
|
||||
extraUtils = [
|
||||
pkgs.fbv
|
||||
];
|
||||
contents = [
|
||||
{ object = ../temp-splash.png; symlink = "/splash.png"; }
|
||||
];
|
||||
};
|
||||
}
|
@ -17,19 +17,32 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config.mobile.boot.stage-1 = lib.mkIf cfg.enable {
|
||||
init = lib.mkOrder AFTER_FRAMEBUFFER_INIT ''
|
||||
show_splash() {
|
||||
config.mobile.boot.stage-1 = lib.mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
init = lib.mkOrder AFTER_FRAMEBUFFER_INIT ''
|
||||
show_splash() {
|
||||
echo | fbv -caferi /$1.png > /dev/null 2>&1
|
||||
}
|
||||
}
|
||||
|
||||
show_splash loading
|
||||
'';
|
||||
extraUtils = [
|
||||
pkgs.fbv
|
||||
];
|
||||
contents = [
|
||||
{ object = ../loading.png; symlink = "/loading.png"; }
|
||||
];
|
||||
};
|
||||
show_splash loading
|
||||
'';
|
||||
extraUtils = [
|
||||
pkgs.fbv
|
||||
];
|
||||
contents = [
|
||||
{ object = ../loading.png; symlink = "/loading.png"; }
|
||||
];
|
||||
}
|
||||
{
|
||||
init = lib.mkOrder READY_INIT ''
|
||||
show_splash splash
|
||||
'';
|
||||
extraUtils = [
|
||||
pkgs.fbv
|
||||
];
|
||||
contents = [
|
||||
{ object = ../temp-splash.png; symlink = "/splash.png"; }
|
||||
];
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
@ -11,13 +11,11 @@
|
||||
./initrd-base.nix
|
||||
./initrd-devices.nix
|
||||
./initrd-framebuffer.nix
|
||||
./initrd-logger-late.nix
|
||||
./initrd-logger.nix
|
||||
./initrd-loop.nix
|
||||
./initrd-nc-shell.nix
|
||||
./initrd-network.nix
|
||||
./initrd-shell.nix
|
||||
./initrd-splash-late.nix
|
||||
./initrd-splash.nix
|
||||
./initrd-ssh.nix
|
||||
./initrd-telnet.nix
|
||||
|
Loading…
Reference in New Issue
Block a user