{ config, pkgs, lib, ... }: let nomarchyLib = import ../../lib { inherit lib; }; palette = nomarchyLib.getPalette config.nomarchy.system.theme; # Plymouth's Window.SetBackgroundTopColor takes three floats in 0.0–1.0; # the .plymouth metadata's ConsoleLogBackgroundColor takes a 0xRRGGBB # hex. Compute both from palette.base00 so the boot splash matches the # rest of the active theme instead of staying frozen on the hardcoded # Tokyo-Night-ish #1a1b26 it used to ship with. hex = palette.base00; rByte = lib.fromHexString (lib.substring 0 2 hex); gByte = lib.fromHexString (lib.substring 2 2 hex); bByte = lib.fromHexString (lib.substring 4 2 hex); # byte → "0.XXX" decimal string. Nix has no floating-point math, so # multiply first, integer-divide, then format. Plymouth tolerates more # decimals than this (0.1019 etc.) but three digits matches the visual # precision Plymouth renders at and keeps the substitution readable. byteToFloat = n: let thousandths = (n * 1000) / 255; s = toString thousandths; padded = if lib.stringLength s == 1 then "00${s}" else if lib.stringLength s == 2 then "0${s}" else s; in "0.${padded}"; bgR = byteToFloat rByte; bgG = byteToFloat gByte; bgB = byteToFloat bByte; nomarchy-plymouth = pkgs.stdenv.mkDerivation { pname = "nomarchy-plymouth"; version = "1.0"; src = ./plymouth; installPhase = '' mkdir -p $out/share/plymouth/themes/nomarchy cp * $out/share/plymouth/themes/nomarchy/ # Fix path in the plymouth file to point to the nix store sed -i "s|/[a-z]*/share/plymouth/themes/nomarchy|$out/share/plymouth/themes/nomarchy|g" \ $out/share/plymouth/themes/nomarchy/nomarchy.plymouth # Substitute the active theme's base00 in both the .script (RGB # floats for the Window.SetBackground* calls) and the .plymouth # metadata (0xRRGGBB for ConsoleLogBackgroundColor). sed -i \ -e 's|@BG_R@|${bgR}|g' \ -e 's|@BG_G@|${bgG}|g' \ -e 's|@BG_B@|${bgB}|g' \ $out/share/plymouth/themes/nomarchy/nomarchy.script sed -i 's|@BG_HEX@|${hex}|g' \ $out/share/plymouth/themes/nomarchy/nomarchy.plymouth ''; }; in { boot.initrd.systemd.enable = lib.mkDefault true; boot.initrd.verbose = lib.mkDefault false; console.earlySetup = lib.mkDefault true; boot.consoleLogLevel = lib.mkDefault 0; boot.plymouth = { enable = lib.mkDefault true; themePackages = lib.mkDefault [ nomarchy-plymouth ]; theme = lib.mkDefault "nomarchy"; }; boot.kernelParams = lib.mkDefault [ "quiet" "splash" "loglevel=3" "rd.systemd.show_status=false" "rd.udev.log_level=3" "udev.log_priority=3" "boot.shell_on_fail" ]; }