Skip to content

Commit 660b9cf

Browse files
authored
nixos/plymouth: fix theme == "breeze" breakage after removing Plasma 5 (#438418)
2 parents a1d5232 + e9e0a09 commit 660b9cf

File tree

1 file changed

+113
-99
lines changed

1 file changed

+113
-99
lines changed

nixos/modules/system/boot/plymouth.nix

Lines changed: 113 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ let
1717
cfg = config.boot.plymouth;
1818
opt = options.boot.plymouth;
1919

20+
nixosBreezePlymouth = pkgs.kdePackages.breeze-plymouth.override {
21+
logoFile = cfg.logo;
22+
logoName = "nixos";
23+
osName = "NixOS";
24+
osVersion = config.system.nixos.release;
25+
};
26+
2027
plymouthLogos = pkgs.runCommand "plymouth-logos" { inherit (cfg) logo; } ''
2128
mkdir -p $out
2229
@@ -60,6 +67,14 @@ let
6067
${cfg.extraConfig}
6168
'';
6269

70+
checkIfThemeExists = ''
71+
# Check if the actual requested theme is here
72+
if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then
73+
echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages"
74+
echo "The following themes exist: $(ls ${themesEnv}/share/plymouth/themes/)"
75+
exit 1
76+
fi
77+
'';
6378
in
6479

6580
{
@@ -80,7 +95,12 @@ in
8095
};
8196

8297
themePackages = mkOption {
83-
default = [ ];
98+
default = lib.optional (cfg.theme == "breeze") nixosBreezePlymouth;
99+
defaultText = literalMD ''
100+
A NixOS branded variant of the breeze theme when
101+
`config.${opt.theme} == "breeze"`, otherwise
102+
`[ ]`.
103+
'';
84104
type = types.listOf types.package;
85105
description = ''
86106
Extra theme packages for plymouth.
@@ -176,48 +196,42 @@ in
176196
"/etc/plymouth/logo.png".source = cfg.logo;
177197
"/etc/plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouthd.defaults";
178198
# Directories
179-
"/etc/plymouth/plugins".source = pkgs.runCommand "plymouth-initrd-plugins" { } ''
180-
# Check if the actual requested theme is here
181-
if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then
182-
echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages"
183-
exit 1
184-
fi
185-
186-
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
187-
188-
mkdir -p $out/renderers
189-
# module might come from a theme
190-
cp ${themesEnv}/lib/plymouth/*.so $out
191-
cp ${plymouth}/lib/plymouth/renderers/*.so $out/renderers
192-
# useless in the initrd, and adds several megabytes to the closure
193-
rm $out/renderers/x11.so
194-
'';
195-
"/etc/plymouth/themes".source = pkgs.runCommand "plymouth-initrd-themes" { } ''
196-
# Check if the actual requested theme is here
197-
if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then
198-
echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages"
199-
exit 1
200-
fi
201-
202-
mkdir -p $out/${cfg.theme}
203-
cp -r ${themesEnv}/share/plymouth/themes/${cfg.theme}/* $out/${cfg.theme}
204-
# Copy more themes if the theme depends on others
205-
for theme in $(grep -hRo '/share/plymouth/themes/.*$' $out | xargs -n1 basename); do
206-
if [[ -d "${themesEnv}/share/plymouth/themes/$theme" ]]; then
207-
if [[ ! -d "$out/$theme" ]]; then
208-
echo "Adding dependent theme: $theme"
209-
mkdir -p "$out/$theme"
210-
cp -r "${themesEnv}/share/plymouth/themes/$theme"/* "$out/$theme"
211-
fi
212-
else
213-
echo "Missing theme dependency: $theme"
214-
fi
215-
done
216-
# Fixup references
217-
for theme in $out/*/*.plymouth; do
218-
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out," "$theme"
219-
done
220-
'';
199+
"/etc/plymouth/plugins".source = pkgs.runCommand "plymouth-initrd-plugins" { } (
200+
checkIfThemeExists
201+
+ ''
202+
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
203+
204+
mkdir -p $out/renderers
205+
# module might come from a theme
206+
cp ${themesEnv}/lib/plymouth/*.so $out
207+
cp ${plymouth}/lib/plymouth/renderers/*.so $out/renderers
208+
# useless in the initrd, and adds several megabytes to the closure
209+
rm $out/renderers/x11.so
210+
''
211+
);
212+
"/etc/plymouth/themes".source = pkgs.runCommand "plymouth-initrd-themes" { } (
213+
checkIfThemeExists
214+
+ ''
215+
mkdir -p $out/${cfg.theme}
216+
cp -r ${themesEnv}/share/plymouth/themes/${cfg.theme}/* $out/${cfg.theme}
217+
# Copy more themes if the theme depends on others
218+
for theme in $(grep -hRo '/share/plymouth/themes/.*$' $out | xargs -n1 basename); do
219+
if [[ -d "${themesEnv}/share/plymouth/themes/$theme" ]]; then
220+
if [[ ! -d "$out/$theme" ]]; then
221+
echo "Adding dependent theme: $theme"
222+
mkdir -p "$out/$theme"
223+
cp -r "${themesEnv}/share/plymouth/themes/$theme"/* "$out/$theme"
224+
fi
225+
else
226+
echo "Missing theme dependency: $theme"
227+
fi
228+
done
229+
# Fixup references
230+
for theme in $out/*/*.plymouth; do
231+
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out," "$theme"
232+
done
233+
''
234+
);
221235

222236
# Fonts
223237
"/etc/plymouth/fonts".source = pkgs.runCommand "plymouth-initrd-fonts" { } ''
@@ -271,62 +285,62 @@ in
271285
'')
272286
];
273287

274-
boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
275-
copy_bin_and_libs ${plymouth}/bin/plymouth
276-
copy_bin_and_libs ${plymouth}/bin/plymouthd
277-
278-
# Check if the actual requested theme is here
279-
if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then
280-
echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages"
281-
exit 1
282-
fi
283-
284-
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
285-
286-
mkdir -p $out/lib/plymouth/renderers
287-
# module might come from a theme
288-
cp ${themesEnv}/lib/plymouth/*.so $out/lib/plymouth
289-
cp ${plymouth}/lib/plymouth/renderers/*.so $out/lib/plymouth/renderers
290-
# useless in the initrd, and adds several megabytes to the closure
291-
rm $out/lib/plymouth/renderers/x11.so
292-
293-
mkdir -p $out/share/plymouth/themes
294-
cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth
295-
296-
# Copy themes into working directory for patching
297-
mkdir themes
298-
299-
# Use -L to copy the directories proper, not the symlinks to them.
300-
# Copy all themes because they're not large assets, and bgrt depends on the ImageDir of
301-
# the spinner theme.
302-
cp -r -L ${themesEnv}/share/plymouth/themes/* themes
303-
304-
# Patch out any attempted references to the theme or plymouth's themes directory
305-
chmod -R +w themes
306-
find themes -type f | while read file
307-
do
308-
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file
309-
done
310-
311-
# Install themes
312-
cp -r themes/* $out/share/plymouth/themes
313-
314-
# Install logo
315-
mkdir -p $out/etc/plymouth
316-
cp -r -L ${themesEnv}/etc/plymouth $out/etc
317-
318-
# Setup font
319-
mkdir -p $out/share/fonts
320-
cp ${cfg.font} $out/share/fonts
321-
mkdir -p $out/etc/fonts
322-
cat > $out/etc/fonts/fonts.conf <<EOF
323-
<?xml version="1.0"?>
324-
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
325-
<fontconfig>
326-
<dir>$out/share/fonts</dir>
327-
</fontconfig>
328-
EOF
329-
'';
288+
boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (
289+
''
290+
copy_bin_and_libs ${plymouth}/bin/plymouth
291+
copy_bin_and_libs ${plymouth}/bin/plymouthd
292+
293+
''
294+
+ checkIfThemeExists
295+
+ ''
296+
297+
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
298+
299+
mkdir -p $out/lib/plymouth/renderers
300+
# module might come from a theme
301+
cp ${themesEnv}/lib/plymouth/*.so $out/lib/plymouth
302+
cp ${plymouth}/lib/plymouth/renderers/*.so $out/lib/plymouth/renderers
303+
# useless in the initrd, and adds several megabytes to the closure
304+
rm $out/lib/plymouth/renderers/x11.so
305+
306+
mkdir -p $out/share/plymouth/themes
307+
cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth
308+
309+
# Copy themes into working directory for patching
310+
mkdir themes
311+
312+
# Use -L to copy the directories proper, not the symlinks to them.
313+
# Copy all themes because they're not large assets, and bgrt depends on the ImageDir of
314+
# the spinner theme.
315+
cp -r -L ${themesEnv}/share/plymouth/themes/* themes
316+
317+
# Patch out any attempted references to the theme or plymouth's themes directory
318+
chmod -R +w themes
319+
find themes -type f | while read file
320+
do
321+
sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file
322+
done
323+
324+
# Install themes
325+
cp -r themes/* $out/share/plymouth/themes
326+
327+
# Install logo
328+
mkdir -p $out/etc/plymouth
329+
cp -r -L ${themesEnv}/etc/plymouth $out/etc
330+
331+
# Setup font
332+
mkdir -p $out/share/fonts
333+
cp ${cfg.font} $out/share/fonts
334+
mkdir -p $out/etc/fonts
335+
cat > $out/etc/fonts/fonts.conf <<EOF
336+
<?xml version="1.0"?>
337+
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
338+
<fontconfig>
339+
<dir>$out/share/fonts</dir>
340+
</fontconfig>
341+
EOF
342+
''
343+
);
330344

331345
boot.initrd.extraUtilsCommandsTest = mkIf (!config.boot.initrd.systemd.enable) ''
332346
$out/bin/plymouthd --help >/dev/null

0 commit comments

Comments
 (0)