@@ -4,8 +4,7 @@ with lib;
44
55let
66
7- inherit ( pkgs ) plymouth ;
8- inherit ( pkgs ) nixos-icons ;
7+ inherit ( pkgs ) plymouth nixos-icons ;
98
109 cfg = config . boot . plymouth ;
1110
1615 osVersion = config . system . nixos . release ;
1716 } ;
1817
18+ plymouthLogos = pkgs . runCommand "plymouth-logos" { inherit ( cfg ) logo ; } ''
19+ mkdir -p $out
20+
21+ # For themes that are compiled with PLYMOUTH_LOGO_FILE
22+ mkdir -p $out/etc/plymouth
23+ ln -s $logo $out/etc/plymouth/logo.png
24+
25+ # Logo for bgrt theme
26+ # Note this is technically an abuse of watermark for the bgrt theme
27+ # See: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/95#note_813768
28+ mkdir -p $out/share/plymouth/themes/spinner
29+ ln -s $logo $out/share/plymouth/themes/spinner/watermark.png
30+
31+ # Logo for spinfinity theme
32+ # See: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/106
33+ mkdir -p $out/share/plymouth/themes/spinfinity
34+ ln -s $logo $out/share/plymouth/themes/spinfinity/header-image.png
35+ '' ;
36+
1937 themesEnv = pkgs . buildEnv {
2038 name = "plymouth-themes" ;
21- paths = [ plymouth ] ++ cfg . themePackages ;
39+ paths = [
40+ plymouth
41+ plymouthLogos
42+ ] ++ cfg . themePackages ;
2243 } ;
2344
2445 configFile = pkgs . writeText "plymouthd.conf" ''
2546 [Daemon]
2647 ShowDelay=0
48+ DeviceTimeout=8
2749 Theme=${ cfg . theme }
2850 ${ cfg . extraConfig }
2951 '' ;
4769 } ;
4870
4971 themePackages = mkOption {
50- default = [ nixosBreezePlymouth ] ;
72+ default = lib . optional ( cfg . theme == "breeze" ) nixosBreezePlymouth ;
5173 type = types . listOf types . package ;
5274 description = ''
5375 Extra theme packages for plymouth.
5476 '' ;
5577 } ;
5678
5779 theme = mkOption {
58- default = "breeze " ;
80+ default = "bgrt " ;
5981 type = types . str ;
6082 description = ''
6183 Splash screen theme.
6486
6587 logo = mkOption {
6688 type = types . path ;
67- default = "${ nixos-icons } /share/icons/hicolor/128x128/apps/nix-snowflake.png" ;
89+ # Dimensions are 48x48 to match GDM logo
90+ default = "${ nixos-icons } /share/icons/hicolor/48x48/apps/nix-snowflake-white.png" ;
6891 defaultText = ''pkgs.fetchurl {
6992 url = "https://nixos.org/logo/nixos-hires.png";
7093 sha256 = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
110133 systemd . services . plymouth-poweroff . wantedBy = [ "poweroff.target" ] ;
111134 systemd . services . plymouth-reboot . wantedBy = [ "reboot.target" ] ;
112135 systemd . services . plymouth-read-write . wantedBy = [ "sysinit.target" ] ;
113- systemd . services . systemd-ask-password-plymouth . wantedBy = [ "multi-user.target" ] ;
114- systemd . paths . systemd-ask-password-plymouth . wantedBy = [ "multi-user.target" ] ;
136+ systemd . services . systemd-ask-password-plymouth . wantedBy = [ "multi-user.target" ] ;
137+ systemd . paths . systemd-ask-password-plymouth . wantedBy = [ "multi-user.target" ] ;
115138
116139 boot . initrd . extraUtilsCommands = ''
117- copy_bin_and_libs ${ pkgs . plymouth } /bin/plymouthd
118- copy_bin_and_libs ${ pkgs . plymouth } /bin/plymouth
140+ copy_bin_and_libs ${ plymouth } /bin/plymouth
141+ copy_bin_and_libs ${ plymouth } /bin/plymouthd
142+
143+ # Check if the actual requested theme is here
144+ if [[ ! -d ${ themesEnv } /share/plymouth/themes/${ cfg . theme } ]]; then
145+ echo "The requested theme: ${ cfg . theme } is not provided by any of the packages in boot.plymouth.themePackages"
146+ exit 1
147+ fi
119148
120149 moduleName="$(sed -n 's,ModuleName *= *,,p' ${ themesEnv } /share/plymouth/themes/${ cfg . theme } /${ cfg . theme } .plymouth)"
121150
127156 mkdir -p $out/share/plymouth/themes
128157 cp ${ plymouth } /share/plymouth/plymouthd.defaults $out/share/plymouth
129158
130- # copy themes into working directory for patching
159+ # Copy themes into working directory for patching
131160 mkdir themes
132- # use -L to copy the directories proper, not the symlinks to them
133- cp -r -L ${ themesEnv } /share/plymouth/themes/{text,details,${ cfg . theme } } themes
134161
135- # patch out any attempted references to the theme or plymouth's themes directory
162+ # Use -L to copy the directories proper, not the symlinks to them.
163+ # Copy all themes because they're not large assets, and bgrt depends on the ImageDir of
164+ # the spinner theme.
165+ cp -r -L ${ themesEnv } /share/plymouth/themes/* themes
166+
167+ # Patch out any attempted references to the theme or plymouth's themes directory
136168 chmod -R +w themes
137169 find themes -type f | while read file
138170 do
139171 sed -i "s,/nix/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file
140172 done
141173
174+ # Install themes
142175 cp -r themes/* $out/share/plymouth/themes
143- cp ${ cfg . logo } $out/share/plymouth/logo.png
144176
177+ # Install logo
178+ mkdir -p $out/etc/plymouth
179+ cp -r -L ${ themesEnv } /etc/plymouth $out
180+
181+ # Setup font
145182 mkdir -p $out/share/fonts
146183 cp ${ cfg . font } $out/share/fonts
147184 mkdir -p $out/etc/fonts
0 commit comments