Skip to content

Commit 583f1a9

Browse files
authored
Merge pull request NixOS#114000 from worldofpeace/plymouth-bgrt
nixos/plymouth: use bgrt theme
2 parents 96e9a7c + 9e84dc0 commit 583f1a9

File tree

2 files changed

+127
-43
lines changed

2 files changed

+127
-43
lines changed

nixos/modules/system/boot/plymouth.nix

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ with lib;
44

55
let
66

7-
inherit (pkgs) plymouth;
8-
inherit (pkgs) nixos-icons;
7+
inherit (pkgs) plymouth nixos-icons;
98

109
cfg = config.boot.plymouth;
1110

@@ -16,14 +15,37 @@ let
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
'';
@@ -47,15 +69,15 @@ in
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.
@@ -64,7 +86,8 @@ in
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";
@@ -110,12 +133,18 @@ in
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
@@ -127,21 +156,29 @@ in
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
Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,111 @@
1-
{ stdenv, fetchurl, autoreconfHook, pkg-config, libxslt, docbook_xsl
2-
, gtk3, udev, systemd, lib
1+
{ lib
2+
, stdenv
3+
, fetchpatch
4+
, fetchFromGitLab
5+
, pkg-config
6+
, autoreconfHook
7+
, libxslt
8+
, docbook-xsl-nons
9+
, gettext
10+
, gtk3
11+
, systemd
12+
, pango
13+
, cairo
14+
, libdrm
315
}:
416

517
stdenv.mkDerivation rec {
6-
pname = "plymouth";
7-
version = "0.9.4";
18+
pname = "plymouth-unstable";
19+
version = "2020-12-07";
820

9-
src = fetchurl {
10-
url = "https://www.freedesktop.org/software/plymouth/releases/${pname}-${version}.tar.xz";
11-
sha256 = "0l8kg7b2vfxgz9gnrn0v2w4jvysj2cirp0nxads5sy05397pl6aa";
21+
outputs = [
22+
"out"
23+
"dev"
24+
];
25+
26+
src = fetchFromGitLab {
27+
domain = "gitlab.freedesktop.org";
28+
owner = "plymouth";
29+
repo = "plymouth";
30+
rev = "c4ced2a2d70edea7fbb95274aa1d01d95928df1b";
31+
sha256 = "7CPuKMA0fTt8DBsaA4Td74kHT/O7PW8N3awP04nUnOI=";
1232
};
1333

1434
nativeBuildInputs = [
15-
autoreconfHook pkg-config libxslt docbook_xsl
35+
autoreconfHook
36+
docbook-xsl-nons
37+
gettext
38+
libxslt
39+
pkg-config
1640
];
1741

1842
buildInputs = [
19-
gtk3 udev systemd
43+
cairo
44+
gtk3
45+
libdrm
46+
pango
47+
systemd
48+
];
49+
50+
patches = [
51+
# KillMode=none is deprecated
52+
# https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/123
53+
(fetchpatch {
54+
url = "https://gitlab.freedesktop.org/plymouth/plymouth/-/commit/b406b0895a95949db2adfedaeda451f36f2b51c3.patch";
55+
sha256 = "/UBImNuFO0G/oxlttjGIXon8YXMXlc9XU8uVuR9QuxY=";
56+
})
2057
];
2158

2259
postPatch = ''
2360
sed -i \
24-
-e "s#\$(\$PKG_CONFIG --variable=systemdsystemunitdir systemd)#$out/etc/systemd/system#g" \
2561
-e "s#plymouthplugindir=.*#plymouthplugindir=/etc/plymouth/plugins/#" \
2662
-e "s#plymouththemedir=.*#plymouththemedir=/etc/plymouth/themes#" \
2763
-e "s#plymouthpolicydir=.*#plymouthpolicydir=/etc/plymouth/#" \
64+
-e "s#plymouthconfdir=.*#plymouthconfdir=/etc/plymouth/#" \
2865
configure.ac
2966
'';
3067

68+
configurePlatforms = [ "host" ];
69+
3170
configureFlags = [
32-
"--sysconfdir=/etc"
33-
"--with-systemdunitdir=${placeholder "out"}/etc/systemd/system"
71+
"--enable-documentation"
72+
"--enable-drm"
73+
"--enable-gtk"
74+
"--enable-pango"
75+
"--enable-systemd-integration"
76+
"--enable-tracing"
3477
"--localstatedir=/var"
35-
"--with-logo=/etc/plymouth/logo.png"
78+
"--sysconfdir=/etc"
3679
"--with-background-color=0x000000"
37-
"--with-background-start-color-stop=0x000000"
3880
"--with-background-end-color-stop=0x000000"
81+
"--with-background-start-color-stop=0x000000"
82+
"--with-logo=/etc/plymouth/logo.png"
3983
"--with-release-file=/etc/os-release"
40-
"--without-system-root-install"
84+
"--with-runtimedir=/run"
85+
"--with-systemdunitdir=${placeholder "out"}/etc/systemd/system"
4186
"--without-rhgb-compat-link"
42-
"--enable-tracing"
43-
"--enable-systemd-integration"
44-
"--enable-pango"
45-
"--enable-gdm-transition"
46-
"--enable-gtk"
87+
"--without-system-root-install"
4788
"ac_cv_path_SYSTEMD_ASK_PASSWORD_AGENT=${lib.getBin systemd}/bin/systemd-tty-ask-password-agent"
4889
];
4990

50-
configurePlatforms = [ "host" ];
51-
5291
installFlags = [
53-
"plymouthd_defaultsdir=$(out)/share/plymouth"
54-
"plymouthd_confdir=$(out)/etc/plymouth"
92+
"localstatedir=\${TMPDIR}"
93+
"plymouthd_confdir=${placeholder "out"}/etc/plymouth"
94+
"plymouthd_defaultsdir=${placeholder "out"}/share/plymouth"
95+
"sysconfdir=${placeholder "out"}/etc"
5596
];
5697

98+
postInstall = ''
99+
# Makes a symlink to /usr/share/pixmaps/system-logo-white.png
100+
# We'll handle it in the nixos module.
101+
rm $out/share/plymouth/themes/spinfinity/header-image.png
102+
'';
103+
57104
meta = with lib; {
58-
homepage = "http://www.freedesktop.org/wiki/Software/Plymouth";
59-
description = "A graphical boot animation";
60-
license = licenses.gpl2;
61-
maintainers = [ maintainers.goibhniu ];
105+
homepage = "https://www.freedesktop.org/wiki/Software/Plymouth/";
106+
description = "Boot splash and boot logger";
107+
license = licenses.gpl2Plus;
108+
maintainers = [ maintainers.goibhniu teams.gnome.members ];
62109
platforms = platforms.linux;
63110
};
64111
}

0 commit comments

Comments
 (0)