···
cfg = config.boot.plymouth;
opt = options.boot.plymouth;
+
nixosBreezePlymouth = pkgs.kdePackages.breeze-plymouth.override {
+
osVersion = config.system.nixos.release;
plymouthLogos = pkgs.runCommand "plymouth-logos" { inherit (cfg) logo; } ''
···
+
checkIfThemeExists = ''
+
# Check if the actual requested theme is here
+
if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then
+
echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages"
+
echo "The following themes exist: $(ls ${themesEnv}/share/plymouth/themes/)"
···
themePackages = mkOption {
+
default = lib.optional (cfg.theme == "breeze") nixosBreezePlymouth;
+
defaultText = literalMD ''
+
A NixOS branded variant of the breeze theme when
+
`config.${opt.theme} == "breeze"`, otherwise
type = types.listOf types.package;
Extra theme packages for plymouth.
···
"/etc/plymouth/logo.png".source = cfg.logo;
"/etc/plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouthd.defaults";
+
"/etc/plymouth/plugins".source = pkgs.runCommand "plymouth-initrd-plugins" { } (
+
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
+
mkdir -p $out/renderers
+
# module might come from a theme
+
cp ${themesEnv}/lib/plymouth/*.so $out
+
cp ${plymouth}/lib/plymouth/renderers/*.so $out/renderers
+
# useless in the initrd, and adds several megabytes to the closure
+
rm $out/renderers/x11.so
+
"/etc/plymouth/themes".source = pkgs.runCommand "plymouth-initrd-themes" { } (
+
mkdir -p $out/${cfg.theme}
+
cp -r ${themesEnv}/share/plymouth/themes/${cfg.theme}/* $out/${cfg.theme}
+
# Copy more themes if the theme depends on others
+
for theme in $(grep -hRo '/share/plymouth/themes/.*$' $out | xargs -n1 basename); do
+
if [[ -d "${themesEnv}/share/plymouth/themes/$theme" ]]; then
+
if [[ ! -d "$out/$theme" ]]; then
+
echo "Adding dependent theme: $theme"
+
cp -r "${themesEnv}/share/plymouth/themes/$theme"/* "$out/$theme"
+
echo "Missing theme dependency: $theme"
+
for theme in $out/*/*.plymouth; do
+
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out," "$theme"
"/etc/plymouth/fonts".source = pkgs.runCommand "plymouth-initrd-fonts" { } ''
···
+
boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (
+
copy_bin_and_libs ${plymouth}/bin/plymouth
+
copy_bin_and_libs ${plymouth}/bin/plymouthd
+
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
+
mkdir -p $out/lib/plymouth/renderers
+
# module might come from a theme
+
cp ${themesEnv}/lib/plymouth/*.so $out/lib/plymouth
+
cp ${plymouth}/lib/plymouth/renderers/*.so $out/lib/plymouth/renderers
+
# useless in the initrd, and adds several megabytes to the closure
+
rm $out/lib/plymouth/renderers/x11.so
+
mkdir -p $out/share/plymouth/themes
+
cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth
+
# Copy themes into working directory for patching
+
# Use -L to copy the directories proper, not the symlinks to them.
+
# Copy all themes because they're not large assets, and bgrt depends on the ImageDir of
+
cp -r -L ${themesEnv}/share/plymouth/themes/* themes
+
# Patch out any attempted references to the theme or plymouth's themes directory
+
find themes -type f | while read file
+
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file
+
cp -r themes/* $out/share/plymouth/themes
+
mkdir -p $out/etc/plymouth
+
cp -r -L ${themesEnv}/etc/plymouth $out/etc
+
mkdir -p $out/share/fonts
+
cp ${cfg.font} $out/share/fonts
+
mkdir -p $out/etc/fonts
+
cat > $out/etc/fonts/fonts.conf <<EOF
+
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
+
<dir>$out/share/fonts</dir>
boot.initrd.extraUtilsCommandsTest = mkIf (!config.boot.initrd.systemd.enable) ''
$out/bin/plymouthd --help >/dev/null