|
67 | 67 | ${cfg.extraConfig} |
68 | 68 | ''; |
69 | 69 |
|
| 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 | + ''; |
70 | 78 | in |
71 | 79 |
|
72 | 80 | { |
|
188 | 196 | "/etc/plymouth/logo.png".source = cfg.logo; |
189 | 197 | "/etc/plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouthd.defaults"; |
190 | 198 | # Directories |
191 | | - "/etc/plymouth/plugins".source = pkgs.runCommand "plymouth-initrd-plugins" { } '' |
192 | | - # Check if the actual requested theme is here |
193 | | - if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then |
194 | | - echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages" |
195 | | - echo "The following themes exist: $(ls ${themesEnv}/share/plymouth/themes/)" |
196 | | - exit 1 |
197 | | - fi |
198 | | -
|
199 | | - moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)" |
200 | | -
|
201 | | - mkdir -p $out/renderers |
202 | | - # module might come from a theme |
203 | | - cp ${themesEnv}/lib/plymouth/*.so $out |
204 | | - cp ${plymouth}/lib/plymouth/renderers/*.so $out/renderers |
205 | | - # useless in the initrd, and adds several megabytes to the closure |
206 | | - rm $out/renderers/x11.so |
207 | | - ''; |
208 | | - "/etc/plymouth/themes".source = pkgs.runCommand "plymouth-initrd-themes" { } '' |
209 | | - # Check if the actual requested theme is here |
210 | | - if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then |
211 | | - echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages" |
212 | | - echo "The following themes exist: $(ls ${themesEnv}/share/plymouth/themes/)" |
213 | | - exit 1 |
214 | | - fi |
215 | | -
|
216 | | - mkdir -p $out/${cfg.theme} |
217 | | - cp -r ${themesEnv}/share/plymouth/themes/${cfg.theme}/* $out/${cfg.theme} |
218 | | - # Copy more themes if the theme depends on others |
219 | | - for theme in $(grep -hRo '/share/plymouth/themes/.*$' $out | xargs -n1 basename); do |
220 | | - if [[ -d "${themesEnv}/share/plymouth/themes/$theme" ]]; then |
221 | | - if [[ ! -d "$out/$theme" ]]; then |
222 | | - echo "Adding dependent theme: $theme" |
223 | | - mkdir -p "$out/$theme" |
224 | | - cp -r "${themesEnv}/share/plymouth/themes/$theme"/* "$out/$theme" |
225 | | - fi |
226 | | - else |
227 | | - echo "Missing theme dependency: $theme" |
228 | | - fi |
229 | | - done |
230 | | - # Fixup references |
231 | | - for theme in $out/*/*.plymouth; do |
232 | | - sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out," "$theme" |
233 | | - done |
234 | | - ''; |
| 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 | + ); |
235 | 235 |
|
236 | 236 | # Fonts |
237 | 237 | "/etc/plymouth/fonts".source = pkgs.runCommand "plymouth-initrd-fonts" { } '' |
|
285 | 285 | '') |
286 | 286 | ]; |
287 | 287 |
|
288 | | - boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' |
289 | | - copy_bin_and_libs ${plymouth}/bin/plymouth |
290 | | - copy_bin_and_libs ${plymouth}/bin/plymouthd |
291 | | -
|
292 | | - # Check if the actual requested theme is here |
293 | | - if [[ ! -d ${themesEnv}/share/plymouth/themes/${cfg.theme} ]]; then |
294 | | - echo "The requested theme: ${cfg.theme} is not provided by any of the packages in boot.plymouth.themePackages" |
295 | | - echo "The following themes exist: $(ls ${themesEnv}/share/plymouth/themes/)" |
296 | | - exit 1 |
297 | | - fi |
298 | | -
|
299 | | - moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)" |
300 | | -
|
301 | | - mkdir -p $out/lib/plymouth/renderers |
302 | | - # module might come from a theme |
303 | | - cp ${themesEnv}/lib/plymouth/*.so $out/lib/plymouth |
304 | | - cp ${plymouth}/lib/plymouth/renderers/*.so $out/lib/plymouth/renderers |
305 | | - # useless in the initrd, and adds several megabytes to the closure |
306 | | - rm $out/lib/plymouth/renderers/x11.so |
307 | | -
|
308 | | - mkdir -p $out/share/plymouth/themes |
309 | | - cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth |
310 | | -
|
311 | | - # Copy themes into working directory for patching |
312 | | - mkdir themes |
313 | | -
|
314 | | - # Use -L to copy the directories proper, not the symlinks to them. |
315 | | - # Copy all themes because they're not large assets, and bgrt depends on the ImageDir of |
316 | | - # the spinner theme. |
317 | | - cp -r -L ${themesEnv}/share/plymouth/themes/* themes |
318 | | -
|
319 | | - # Patch out any attempted references to the theme or plymouth's themes directory |
320 | | - chmod -R +w themes |
321 | | - find themes -type f | while read file |
322 | | - do |
323 | | - sed -i "s,${builtins.storeDir}/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file |
324 | | - done |
325 | | -
|
326 | | - # Install themes |
327 | | - cp -r themes/* $out/share/plymouth/themes |
328 | | -
|
329 | | - # Install logo |
330 | | - mkdir -p $out/etc/plymouth |
331 | | - cp -r -L ${themesEnv}/etc/plymouth $out/etc |
332 | | -
|
333 | | - # Setup font |
334 | | - mkdir -p $out/share/fonts |
335 | | - cp ${cfg.font} $out/share/fonts |
336 | | - mkdir -p $out/etc/fonts |
337 | | - cat > $out/etc/fonts/fonts.conf <<EOF |
338 | | - <?xml version="1.0"?> |
339 | | - <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> |
340 | | - <fontconfig> |
341 | | - <dir>$out/share/fonts</dir> |
342 | | - </fontconfig> |
343 | | - EOF |
344 | | - ''; |
| 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 | + ); |
345 | 344 |
|
346 | 345 | boot.initrd.extraUtilsCommandsTest = mkIf (!config.boot.initrd.systemd.enable) '' |
347 | 346 | $out/bin/plymouthd --help >/dev/null |
|
0 commit comments