From 629c936fd22637ec58a37313aadbd47823114cb8 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Wed, 13 Nov 2024 01:54:03 -0500 Subject: [PATCH] nixos/plymouth: Respect plymouth.enable=0 in scripted stage 1 Removing the splash param only causes plymouth to display console output by default; it still runs. Systemd stage 1 respects this flag due to unit conditions preventing plymouth from even running. So this brings parity to scripted stage 1. --- nixos/modules/system/boot/plymouth.nix | 39 ++++++++++++++++++-------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/nixos/modules/system/boot/plymouth.nix b/nixos/modules/system/boot/plymouth.nix index 6b459fa14085..4c5057a05b25 100644 --- a/nixos/modules/system/boot/plymouth.nix +++ b/nixos/modules/system/boot/plymouth.nix @@ -333,26 +333,41 @@ in # We use `mkAfter` to ensure that LUKS password prompt would be shown earlier than the splash screen. boot.initrd.preLVMCommands = mkIf (!config.boot.initrd.systemd.enable) (mkAfter '' - mkdir -p /etc/plymouth - mkdir -p /run/plymouth - ln -s $extraUtils/etc/plymouth/logo.png /etc/plymouth/logo.png - ln -s ${configFile} /etc/plymouth/plymouthd.conf - ln -s $extraUtils/share/plymouth/plymouthd.defaults /run/plymouth/plymouthd.defaults - ln -s $extraUtils/share/plymouth/themes /run/plymouth/themes - ln -s $extraUtils/lib/plymouth /run/plymouth/plugins - ln -s $extraUtils/etc/fonts /etc/fonts + plymouth_enabled=1 + for o in $(cat /proc/cmdline); do + case $o in + plymouth.enable=0) + plymouth_enabled=0 + ;; + esac + done - plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session - plymouth show-splash + if [ "$plymouth_enabled" != 0 ]; then + mkdir -p /etc/plymouth + mkdir -p /run/plymouth + ln -s $extraUtils/etc/plymouth/logo.png /etc/plymouth/logo.png + ln -s ${configFile} /etc/plymouth/plymouthd.conf + ln -s $extraUtils/share/plymouth/plymouthd.defaults /run/plymouth/plymouthd.defaults + ln -s $extraUtils/share/plymouth/themes /run/plymouth/themes + ln -s $extraUtils/lib/plymouth /run/plymouth/plugins + ln -s $extraUtils/etc/fonts /etc/fonts + + plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session + plymouth show-splash + fi ''); boot.initrd.postMountCommands = mkIf (!config.boot.initrd.systemd.enable) '' - plymouth update-root-fs --new-root-dir="$targetRoot" + if [ "$plymouth_enabled" != 0 ]; then + plymouth update-root-fs --new-root-dir="$targetRoot" + fi ''; # `mkBefore` to ensure that any custom prompts would be visible. boot.initrd.preFailCommands = mkIf (!config.boot.initrd.systemd.enable) (mkBefore '' - plymouth quit --wait + if [ "$plymouth_enabled" != 0 ]; then + plymouth quit --wait + fi ''); };