2021-12-05 22:06:49 +01:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2016-07-06 22:00:44 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
inherit (pkgs) plymouth nixos-icons;
|
2016-07-06 22:00:44 +02:00
|
|
|
|
|
|
|
cfg = config.boot.plymouth;
|
2021-12-05 22:06:49 +01:00
|
|
|
opt = options.boot.plymouth;
|
2016-07-06 22:00:44 +02:00
|
|
|
|
2020-12-11 19:52:16 +01:00
|
|
|
nixosBreezePlymouth = pkgs.plasma5Packages.breeze-plymouth.override {
|
2019-09-20 18:00:24 +02:00
|
|
|
logoFile = cfg.logo;
|
|
|
|
logoName = "nixos";
|
|
|
|
osName = "NixOS";
|
|
|
|
osVersion = config.system.nixos.release;
|
2017-12-11 21:42:00 +01:00
|
|
|
};
|
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
plymouthLogos = pkgs.runCommand "plymouth-logos" { inherit (cfg) logo; } ''
|
|
|
|
mkdir -p $out
|
|
|
|
|
|
|
|
# For themes that are compiled with PLYMOUTH_LOGO_FILE
|
|
|
|
mkdir -p $out/etc/plymouth
|
|
|
|
ln -s $logo $out/etc/plymouth/logo.png
|
|
|
|
|
|
|
|
# Logo for bgrt theme
|
|
|
|
# Note this is technically an abuse of watermark for the bgrt theme
|
|
|
|
# See: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/95#note_813768
|
|
|
|
mkdir -p $out/share/plymouth/themes/spinner
|
|
|
|
ln -s $logo $out/share/plymouth/themes/spinner/watermark.png
|
|
|
|
|
|
|
|
# Logo for spinfinity theme
|
|
|
|
# See: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/106
|
|
|
|
mkdir -p $out/share/plymouth/themes/spinfinity
|
|
|
|
ln -s $logo $out/share/plymouth/themes/spinfinity/header-image.png
|
|
|
|
'';
|
|
|
|
|
2016-07-06 22:00:44 +02:00
|
|
|
themesEnv = pkgs.buildEnv {
|
|
|
|
name = "plymouth-themes";
|
2021-02-22 13:40:00 +01:00
|
|
|
paths = [
|
|
|
|
plymouth
|
|
|
|
plymouthLogos
|
|
|
|
] ++ cfg.themePackages;
|
2016-07-06 22:00:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "plymouthd.conf" ''
|
|
|
|
[Daemon]
|
|
|
|
ShowDelay=0
|
2020-04-08 23:04:57 +02:00
|
|
|
DeviceTimeout=8
|
2016-07-06 22:00:44 +02:00
|
|
|
Theme=${cfg.theme}
|
2019-10-24 22:28:11 +02:00
|
|
|
${cfg.extraConfig}
|
2016-07-06 22:00:44 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
boot.plymouth = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "Plymouth boot splash screen";
|
|
|
|
|
2020-09-28 15:29:27 +02:00
|
|
|
font = mkOption {
|
|
|
|
default = "${pkgs.dejavu_fonts.minimal}/share/fonts/truetype/DejaVuSans.ttf";
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression ''"''${pkgs.dejavu_fonts.minimal}/share/fonts/truetype/DejaVuSans.ttf"'';
|
2020-09-28 15:29:27 +02:00
|
|
|
type = types.path;
|
|
|
|
description = ''
|
|
|
|
Font file made available for displaying text on the splash screen.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-07-06 22:00:44 +02:00
|
|
|
themePackages = mkOption {
|
2021-02-22 13:40:00 +01:00
|
|
|
default = lib.optional (cfg.theme == "breeze") nixosBreezePlymouth;
|
2021-12-05 22:06:49 +01:00
|
|
|
defaultText = literalDocBook ''
|
|
|
|
A NixOS branded variant of the breeze theme when
|
|
|
|
<literal>config.${opt.theme} == "breeze"</literal>, otherwise
|
|
|
|
<literal>[ ]</literal>.
|
|
|
|
'';
|
2016-07-06 22:00:44 +02:00
|
|
|
type = types.listOf types.package;
|
|
|
|
description = ''
|
|
|
|
Extra theme packages for plymouth.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
theme = mkOption {
|
2021-02-22 13:40:00 +01:00
|
|
|
default = "bgrt";
|
2016-07-06 22:00:44 +02:00
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Splash screen theme.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logo = mkOption {
|
|
|
|
type = types.path;
|
2021-02-25 19:50:04 +01:00
|
|
|
# Dimensions are 48x48 to match GDM logo
|
|
|
|
default = "${nixos-icons}/share/icons/hicolor/48x48/apps/nix-snowflake-white.png";
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression ''pkgs.fetchurl {
|
2016-11-21 16:26:03 +01:00
|
|
|
url = "https://nixos.org/logo/nixos-hires.png";
|
|
|
|
sha256 = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
|
|
|
|
}'';
|
2016-07-06 22:00:44 +02:00
|
|
|
description = ''
|
|
|
|
Logo which is displayed on the splash screen.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:28:11 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Literal string to append to <literal>configFile</literal>
|
|
|
|
and the config file generated by the plymouth module.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-07-06 22:00:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
boot.kernelParams = [ "splash" ];
|
|
|
|
|
|
|
|
# To be discoverable by systemd.
|
|
|
|
environment.systemPackages = [ plymouth ];
|
|
|
|
|
|
|
|
environment.etc."plymouth/plymouthd.conf".source = configFile;
|
2017-10-24 19:57:08 +02:00
|
|
|
environment.etc."plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouthd.defaults";
|
2016-07-06 22:00:44 +02:00
|
|
|
environment.etc."plymouth/logo.png".source = cfg.logo;
|
|
|
|
environment.etc."plymouth/themes".source = "${themesEnv}/share/plymouth/themes";
|
|
|
|
# XXX: Needed because we supply a different set of plugins in initrd.
|
|
|
|
environment.etc."plymouth/plugins".source = "${plymouth}/lib/plymouth";
|
|
|
|
|
|
|
|
systemd.packages = [ plymouth ];
|
|
|
|
|
|
|
|
systemd.services.plymouth-kexec.wantedBy = [ "kexec.target" ];
|
|
|
|
systemd.services.plymouth-halt.wantedBy = [ "halt.target" ];
|
2018-05-02 23:10:43 +02:00
|
|
|
systemd.services.plymouth-quit-wait.wantedBy = [ "multi-user.target" ];
|
2019-10-14 11:36:35 +02:00
|
|
|
systemd.services.plymouth-quit.wantedBy = [ "multi-user.target" ];
|
2016-07-06 22:00:44 +02:00
|
|
|
systemd.services.plymouth-poweroff.wantedBy = [ "poweroff.target" ];
|
|
|
|
systemd.services.plymouth-reboot.wantedBy = [ "reboot.target" ];
|
|
|
|
systemd.services.plymouth-read-write.wantedBy = [ "sysinit.target" ];
|
2021-02-22 13:40:00 +01:00
|
|
|
systemd.services.systemd-ask-password-plymouth.wantedBy = [ "multi-user.target" ];
|
|
|
|
systemd.paths.systemd-ask-password-plymouth.wantedBy = [ "multi-user.target" ];
|
2016-07-06 22:00:44 +02:00
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommands = ''
|
2021-02-22 13:40:00 +01:00
|
|
|
copy_bin_and_libs ${plymouth}/bin/plymouth
|
|
|
|
copy_bin_and_libs ${plymouth}/bin/plymouthd
|
2016-07-06 22:00:44 +02:00
|
|
|
|
2021-02-22 13:35:00 +01:00
|
|
|
# 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"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-06 22:00:44 +02:00
|
|
|
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
|
|
|
|
|
|
|
|
mkdir -p $out/lib/plymouth/renderers
|
2017-10-21 23:29:45 +02:00
|
|
|
# module might come from a theme
|
2020-09-28 15:29:27 +02:00
|
|
|
cp ${themesEnv}/lib/plymouth/{text,details,label,$moduleName}.so $out/lib/plymouth
|
2016-07-06 22:00:44 +02:00
|
|
|
cp ${plymouth}/lib/plymouth/renderers/{drm,frame-buffer}.so $out/lib/plymouth/renderers
|
|
|
|
|
|
|
|
mkdir -p $out/share/plymouth/themes
|
|
|
|
cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth
|
2017-10-21 23:29:45 +02:00
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
# Copy themes into working directory for patching
|
2017-10-21 23:29:45 +02:00
|
|
|
mkdir themes
|
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
# 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
|
|
|
|
# the spinner theme.
|
|
|
|
cp -r -L ${themesEnv}/share/plymouth/themes/* themes
|
|
|
|
|
|
|
|
# Patch out any attempted references to the theme or plymouth's themes directory
|
2017-10-21 23:29:45 +02:00
|
|
|
chmod -R +w themes
|
|
|
|
find themes -type f | while read file
|
|
|
|
do
|
|
|
|
sed -i "s,/nix/.*/share/plymouth/themes,$out/share/plymouth/themes,g" $file
|
|
|
|
done
|
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
# Install themes
|
2017-10-21 23:29:45 +02:00
|
|
|
cp -r themes/* $out/share/plymouth/themes
|
2020-09-28 15:29:27 +02:00
|
|
|
|
2021-02-22 13:40:00 +01:00
|
|
|
# Install logo
|
|
|
|
mkdir -p $out/etc/plymouth
|
|
|
|
cp -r -L ${themesEnv}/etc/plymouth $out
|
|
|
|
|
|
|
|
# Setup font
|
2020-09-28 15:29:27 +02:00
|
|
|
mkdir -p $out/share/fonts
|
|
|
|
cp ${cfg.font} $out/share/fonts
|
|
|
|
mkdir -p $out/etc/fonts
|
|
|
|
cat > $out/etc/fonts/fonts.conf <<EOF
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
|
|
|
|
<fontconfig>
|
|
|
|
<dir>$out/share/fonts</dir>
|
|
|
|
</fontconfig>
|
|
|
|
EOF
|
2016-07-06 22:00:44 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommandsTest = ''
|
|
|
|
$out/bin/plymouthd --help >/dev/null
|
|
|
|
$out/bin/plymouth --help >/dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
boot.initrd.extraUdevRulesCommands = ''
|
|
|
|
cp ${config.systemd.package}/lib/udev/rules.d/{70-uaccess,71-seat}.rules $out
|
|
|
|
sed -i '/loginctl/d' $out/71-seat.rules
|
|
|
|
'';
|
|
|
|
|
2016-07-18 12:42:26 +02:00
|
|
|
# We use `mkAfter` to ensure that LUKS password prompt would be shown earlier than the splash screen.
|
2016-07-06 22:00:44 +02:00
|
|
|
boot.initrd.preLVMCommands = mkAfter ''
|
|
|
|
mkdir -p /etc/plymouth
|
2020-06-23 12:09:29 +02:00
|
|
|
mkdir -p /run/plymouth
|
2016-07-06 22:00:44 +02:00
|
|
|
ln -s ${configFile} /etc/plymouth/plymouthd.conf
|
|
|
|
ln -s $extraUtils/share/plymouth/plymouthd.defaults /etc/plymouth/plymouthd.defaults
|
|
|
|
ln -s $extraUtils/share/plymouth/logo.png /etc/plymouth/logo.png
|
|
|
|
ln -s $extraUtils/share/plymouth/themes /etc/plymouth/themes
|
|
|
|
ln -s $extraUtils/lib/plymouth /etc/plymouth/plugins
|
2020-09-28 15:29:27 +02:00
|
|
|
ln -s $extraUtils/etc/fonts /etc/fonts
|
2016-07-06 22:00:44 +02:00
|
|
|
|
|
|
|
plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session
|
2016-07-18 12:42:26 +02:00
|
|
|
plymouth show-splash
|
2016-07-06 22:00:44 +02:00
|
|
|
'';
|
|
|
|
|
2016-07-18 12:40:41 +02:00
|
|
|
boot.initrd.postMountCommands = ''
|
|
|
|
plymouth update-root-fs --new-root-dir="$targetRoot"
|
|
|
|
'';
|
|
|
|
|
2016-07-18 12:43:38 +02:00
|
|
|
# `mkBefore` to ensure that any custom prompts would be visible.
|
|
|
|
boot.initrd.preFailCommands = mkBefore ''
|
|
|
|
plymouth quit --wait
|
|
|
|
'';
|
|
|
|
|
2016-07-06 22:00:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|