feat(modules): boot loader, kernel, plymouth, console
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3b21d570e0
commit
0ca8dd3929
1 changed files with 268 additions and 0 deletions
268
modules/boot.nix
Normal file
268
modules/boot.nix
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
# Omnixient Boot Configuration
|
||||
# Plymouth theming and seamless boot experience
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
cfg = config.omni;
|
||||
omni = config.omni.lib;
|
||||
|
||||
# Import our custom Plymouth theme package
|
||||
plymouth-themes = pkgs.callPackage ../packages/plymouth-theme.nix { };
|
||||
in
|
||||
{
|
||||
config = mkIf (cfg.enable or true) {
|
||||
# Plymouth boot splash configuration
|
||||
boot.plymouth = {
|
||||
enable = true;
|
||||
theme = "omni-${cfg.theme}";
|
||||
themePackages = [ plymouth-themes ];
|
||||
|
||||
# Logo configuration
|
||||
logo = "${plymouth-themes}/share/plymouth/themes/omni-${cfg.theme}/logo.png";
|
||||
};
|
||||
|
||||
# Boot optimization and theming
|
||||
boot = {
|
||||
# Try 7.0 — 6.18/6.19 have SMU deadlocks on Strix Halo (aiolabs/omnixient#26)
|
||||
# Fallback: linuxPackages_6_12 (LTS) if 7.0 is also unstable
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
|
||||
# Kernel parameters for smooth boot
|
||||
kernelParams = [
|
||||
# Quiet boot (suppress most messages)
|
||||
"quiet"
|
||||
# Splash screen
|
||||
"splash"
|
||||
# Reduce log level
|
||||
"loglevel=3"
|
||||
# Disable systemd status messages on console
|
||||
"rd.systemd.show_status=false"
|
||||
"rd.udev.log_level=3"
|
||||
"udev.log_priority=3"
|
||||
# Faster boot
|
||||
"boot.shell_on_fail"
|
||||
# Hide cursor
|
||||
"vt.global_cursor_default=0"
|
||||
# Security: Disable emergency shell access
|
||||
"systemd.debug-shell=0"
|
||||
# Strix Halo GPU stability (aiolabs/omnixient#26)
|
||||
"amdgpu.gfxoff=0" # disable gfxoff power state
|
||||
"amdgpu.ppfeaturemask=0xffff7fff" # disable GFXOFF at PowerPlay level
|
||||
"amdgpu.gpu_recovery=1" # auto-recover from GPU hangs
|
||||
"amdgpu.cwsr_enable=0" # disable CWSR to prevent MES firmware hangs
|
||||
"iommu=pt" # AMD-recommended pass-through for iGPU
|
||||
];
|
||||
|
||||
# Console configuration for seamless experience
|
||||
consoleLogLevel = 0;
|
||||
|
||||
# Boot loader configuration
|
||||
loader = {
|
||||
timeout = 3;
|
||||
efi.canTouchEfiVariables = true;
|
||||
|
||||
systemd-boot = {
|
||||
enable = true;
|
||||
editor = false;
|
||||
configurationLimit = 10;
|
||||
consoleMode = "auto";
|
||||
};
|
||||
};
|
||||
|
||||
# Initial ramdisk
|
||||
initrd = {
|
||||
verbose = false;
|
||||
includeDefaultModules = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Plymouth transition is handled natively by systemd/plymouth integration.
|
||||
|
||||
# Theme switching integration
|
||||
environment.systemPackages = [
|
||||
plymouth-themes
|
||||
|
||||
# Plymouth theme switching script
|
||||
(omni.makeScript "omni-plymouth-theme" "Switch Plymouth boot theme" ''
|
||||
if [ -z "$1" ]; then
|
||||
echo "🎨 Current Plymouth theme: omni-${cfg.theme}"
|
||||
echo
|
||||
echo "Available themes:"
|
||||
ls ${plymouth-themes}/share/plymouth/themes/ | grep "omni-" | sed 's/omni-/ - /'
|
||||
echo
|
||||
echo "Usage: omni-plymouth-theme <theme-name>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
THEME="omni-$1"
|
||||
THEME_PATH="${plymouth-themes}/share/plymouth/themes/$THEME"
|
||||
|
||||
if [ ! -d "$THEME_PATH" ]; then
|
||||
echo "❌ Theme '$1' not found!"
|
||||
echo "Available themes:"
|
||||
ls ${plymouth-themes}/share/plymouth/themes/ | grep "omni-" | sed 's/omni-/ - /'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🎨 Setting Plymouth theme to: $1"
|
||||
|
||||
# Update Plymouth theme
|
||||
sudo ${pkgs.plymouth}/bin/plymouth-set-default-theme "$THEME"
|
||||
|
||||
# Regenerate initrd
|
||||
echo "🔄 Regenerating initrd..."
|
||||
sudo nixos-rebuild boot --flake /etc/nixos#omni
|
||||
|
||||
echo "✅ Plymouth theme updated!"
|
||||
echo "⚠️ Reboot to see the new boot theme"
|
||||
'')
|
||||
|
||||
# Plymouth management utilities
|
||||
(omni.makeScript "omni-boot-preview" "Preview Plymouth theme" ''
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "❌ This command must be run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🎬 Starting Plymouth preview..."
|
||||
echo " Press Ctrl+Alt+F1 to return to console"
|
||||
echo " Press Ctrl+C to stop preview"
|
||||
|
||||
# Kill any running Plymouth instances
|
||||
pkill plymouthd 2>/dev/null || true
|
||||
|
||||
# Start Plymouth in preview mode
|
||||
${pkgs.plymouth}/bin/plymouthd --debug --debug-file=/tmp/plymouth-debug.log
|
||||
${pkgs.plymouth}/bin/plymouth --show-splash
|
||||
|
||||
# Simulate boot progress
|
||||
for i in $(seq 0 5 100); do
|
||||
${pkgs.plymouth}/bin/plymouth --update="boot-progress:$i/100"
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
echo "Plymouth preview running. Check another TTY to see the splash screen."
|
||||
echo "Press Enter to stop..."
|
||||
read -r
|
||||
|
||||
${pkgs.plymouth}/bin/plymouth --quit
|
||||
pkill plymouthd 2>/dev/null || true
|
||||
|
||||
echo "✅ Plymouth preview stopped"
|
||||
'')
|
||||
|
||||
# Boot diagnostics
|
||||
(omni.makeScript "omni-boot-info" "Show boot information and diagnostics" ''
|
||||
echo "🚀 Omnixient Boot Information"
|
||||
echo "═══════════════════════════"
|
||||
echo
|
||||
|
||||
echo "🎨 Plymouth Configuration:"
|
||||
echo " Current Theme: ${cfg.theme}"
|
||||
echo " Theme Package: ${plymouth-themes}"
|
||||
echo " Plymouth Status: $(systemctl is-active plymouth-start.service 2>/dev/null || echo 'inactive')"
|
||||
echo
|
||||
|
||||
echo "⚙️ Boot Configuration:"
|
||||
echo " Boot Loader: $(bootctl status 2>/dev/null | grep 'systemd-boot' || echo 'systemd-boot')"
|
||||
echo " Kernel: $(uname -r)"
|
||||
echo " Boot Time: $(systemd-analyze | head -1)"
|
||||
echo
|
||||
|
||||
echo "📊 Boot Performance:"
|
||||
systemd-analyze blame | head -10
|
||||
echo
|
||||
|
||||
echo "🔧 Boot Services:"
|
||||
echo " Display Manager: $(systemctl is-active display-manager 2>/dev/null || echo 'inactive')"
|
||||
echo " Plymouth: $(systemctl is-active plymouth-*.service 2>/dev/null || echo 'inactive')"
|
||||
echo " Omnixient Transition: $(systemctl is-active omni-boot-transition 2>/dev/null || echo 'inactive')"
|
||||
|
||||
if [ -f "/tmp/plymouth-debug.log" ]; then
|
||||
echo
|
||||
echo "🐛 Plymouth Debug Log (last 10 lines):"
|
||||
tail -10 /tmp/plymouth-debug.log
|
||||
fi
|
||||
'')
|
||||
];
|
||||
|
||||
# Plymouth theme is set declaratively via boot.plymouth.theme above.
|
||||
|
||||
# Font configuration for Plymouth
|
||||
fonts = {
|
||||
packages = with pkgs; [
|
||||
jetbrains-mono
|
||||
cantarell-fonts
|
||||
liberation_ttf
|
||||
dejavu_fonts
|
||||
];
|
||||
|
||||
# Ensure fonts are available early in boot
|
||||
fontDir.enable = true;
|
||||
};
|
||||
|
||||
# Security settings are now included in boot.kernelParams above
|
||||
|
||||
# Optional: LUKS integration for encrypted systems
|
||||
# Plymouth will automatically handle LUKS password prompts when LUKS devices are configured
|
||||
|
||||
# Console and TTY configuration
|
||||
console = {
|
||||
keyMap = "us";
|
||||
earlySetup = true;
|
||||
colors = [
|
||||
# Custom console color palette matching current theme
|
||||
# This will be used before Plymouth starts
|
||||
]
|
||||
++ (
|
||||
if cfg.theme == "tokyo-night" then
|
||||
[
|
||||
"1a1b26"
|
||||
"f7768e"
|
||||
"9ece6a"
|
||||
"e0af68"
|
||||
"7aa2f7"
|
||||
"bb9af7"
|
||||
"7dcfff"
|
||||
"c0caf5"
|
||||
"414868"
|
||||
"f7768e"
|
||||
"9ece6a"
|
||||
"e0af68"
|
||||
"7aa2f7"
|
||||
"bb9af7"
|
||||
"7dcfff"
|
||||
"a9b1d6"
|
||||
]
|
||||
else if cfg.theme == "gruvbox" then
|
||||
[
|
||||
"282828"
|
||||
"cc241d"
|
||||
"98971a"
|
||||
"d79921"
|
||||
"458588"
|
||||
"b16286"
|
||||
"689d6a"
|
||||
"a89984"
|
||||
"928374"
|
||||
"fb4934"
|
||||
"b8bb26"
|
||||
"fabd2f"
|
||||
"83a598"
|
||||
"d3869b"
|
||||
"8ec07c"
|
||||
"ebdbb2"
|
||||
]
|
||||
else
|
||||
[ ]
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue