2016-07-06 20:00:44 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inherit (pkgs) plymouth;
|
|
|
|
|
|
|
|
cfg = config.boot.plymouth;
|
|
|
|
|
2017-12-11 20:42:00 +00:00
|
|
|
breezePlymouth = pkgs.breeze-plymouth.override {
|
|
|
|
nixosBranding = true;
|
2018-02-19 16:05:32 +00:00
|
|
|
nixosVersion = config.system.nixos.release;
|
2017-12-11 20:42:00 +00:00
|
|
|
};
|
|
|
|
|
2016-07-06 20:00:44 +00:00
|
|
|
themesEnv = pkgs.buildEnv {
|
|
|
|
name = "plymouth-themes";
|
2017-12-11 20:42:00 +00:00
|
|
|
paths = [ plymouth breezePlymouth ] ++ cfg.themePackages;
|
2016-07-06 20:00:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "plymouthd.conf" ''
|
|
|
|
[Daemon]
|
|
|
|
ShowDelay=0
|
|
|
|
Theme=${cfg.theme}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
boot.plymouth = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "Plymouth boot splash screen";
|
|
|
|
|
|
|
|
themePackages = mkOption {
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.package;
|
|
|
|
description = ''
|
|
|
|
Extra theme packages for plymouth.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
theme = mkOption {
|
2017-12-11 20:42:00 +00:00
|
|
|
default = "breeze";
|
2016-07-06 20:00:44 +00:00
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Splash screen theme.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logo = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = pkgs.fetchurl {
|
|
|
|
url = "https://nixos.org/logo/nixos-hires.png";
|
|
|
|
sha256 = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
|
|
|
|
};
|
2016-11-21 15:26:03 +00:00
|
|
|
defaultText = ''pkgs.fetchurl {
|
|
|
|
url = "https://nixos.org/logo/nixos-hires.png";
|
|
|
|
sha256 = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
|
|
|
|
}'';
|
2016-07-06 20:00:44 +00:00
|
|
|
description = ''
|
|
|
|
Logo which is displayed on the splash screen.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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 17:57:08 +00:00
|
|
|
environment.etc."plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouthd.defaults";
|
2016-07-06 20:00:44 +00: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 21:10:43 +00:00
|
|
|
systemd.services.plymouth-quit-wait.wantedBy = [ "multi-user.target" ];
|
2016-07-06 20:00:44 +00:00
|
|
|
systemd.services.plymouth-quit = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2018-05-02 21:10:43 +00:00
|
|
|
after = [ "display-manager.service" ];
|
2016-07-06 20:00:44 +00:00
|
|
|
};
|
|
|
|
systemd.services.plymouth-poweroff.wantedBy = [ "poweroff.target" ];
|
|
|
|
systemd.services.plymouth-reboot.wantedBy = [ "reboot.target" ];
|
|
|
|
systemd.services.plymouth-read-write.wantedBy = [ "sysinit.target" ];
|
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommands = ''
|
|
|
|
copy_bin_and_libs ${pkgs.plymouth}/bin/plymouthd
|
|
|
|
copy_bin_and_libs ${pkgs.plymouth}/bin/plymouth
|
|
|
|
|
|
|
|
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
|
|
|
|
|
|
|
|
mkdir -p $out/lib/plymouth/renderers
|
2017-10-21 21:29:45 +00:00
|
|
|
# module might come from a theme
|
|
|
|
cp ${themesEnv}/lib/plymouth/{text,details,$moduleName}.so $out/lib/plymouth
|
2016-07-06 20:00:44 +00: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 21:29:45 +00:00
|
|
|
|
|
|
|
# copy themes into working directory for patching
|
|
|
|
mkdir themes
|
|
|
|
# use -L to copy the directories proper, not the symlinks to them
|
|
|
|
cp -r -L ${themesEnv}/share/plymouth/themes/{text,details,${cfg.theme}} themes
|
|
|
|
|
|
|
|
# patch out any attempted references to the theme or plymouth's themes directory
|
|
|
|
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
|
|
|
|
|
|
|
|
cp -r themes/* $out/share/plymouth/themes
|
2016-07-06 20:00:44 +00:00
|
|
|
cp ${cfg.logo} $out/share/plymouth/logo.png
|
|
|
|
'';
|
|
|
|
|
|
|
|
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 10:42:26 +00:00
|
|
|
# We use `mkAfter` to ensure that LUKS password prompt would be shown earlier than the splash screen.
|
2016-07-06 20:00:44 +00:00
|
|
|
boot.initrd.preLVMCommands = mkAfter ''
|
|
|
|
mkdir -p /etc/plymouth
|
|
|
|
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
|
|
|
|
|
|
|
|
plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session
|
2016-07-18 10:42:26 +00:00
|
|
|
plymouth show-splash
|
2016-07-06 20:00:44 +00:00
|
|
|
'';
|
|
|
|
|
2016-07-18 10:40:41 +00:00
|
|
|
boot.initrd.postMountCommands = ''
|
|
|
|
plymouth update-root-fs --new-root-dir="$targetRoot"
|
|
|
|
'';
|
|
|
|
|
2016-07-18 10:43:38 +00:00
|
|
|
# `mkBefore` to ensure that any custom prompts would be visible.
|
|
|
|
boot.initrd.preFailCommands = mkBefore ''
|
|
|
|
plymouth quit --wait
|
|
|
|
'';
|
|
|
|
|
2016-07-06 20:00:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|