From 97680bd24e0991182d5f83a39bb29369e4daf514 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 12 Apr 2024 23:28:50 +0200 Subject: [PATCH] Add polymouth --- hosts/herugrim/default.nix | 7 +++++++ options/system/boot/default.nix | 1 + options/system/boot/plymouth.nix | 25 +++++++++++++++++++++++++ system/boot/default.nix | 1 + system/boot/plymouth.nix | 28 ++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 options/system/boot/plymouth.nix create mode 100644 system/boot/plymouth.nix diff --git a/hosts/herugrim/default.nix b/hosts/herugrim/default.nix index 00b5a36..7843f5d 100644 --- a/hosts/herugrim/default.nix +++ b/hosts/herugrim/default.nix @@ -47,6 +47,13 @@ boot = { secure-boot.enable = true; tmpOnTmpfs = true; + + # Boot splash screen + plymouth = { + enable = true; + withThemes = true; # enable adi1090x/plymouth-themes + selectedTheme = "colorful_loop"; + }; }; }; diff --git a/options/system/boot/default.nix b/options/system/boot/default.nix index 3b06b2e..b29c5bb 100644 --- a/options/system/boot/default.nix +++ b/options/system/boot/default.nix @@ -5,6 +5,7 @@ in { imports = [ ./secure-boot.nix + ./plymouth.nix ]; options.myOptions.system.boot = { diff --git a/options/system/boot/plymouth.nix b/options/system/boot/plymouth.nix new file mode 100644 index 0000000..bbb5ce6 --- /dev/null +++ b/options/system/boot/plymouth.nix @@ -0,0 +1,25 @@ +{ lib, ... }: with lib; let + inherit (lib) mkEnableOption mkOption types; +in +{ + options.myOptions.system.boot.plymouth = { + enable = mkEnableOption ''Plymouth boot splash.''; + + withThemes = mkEnableOption '' + Whether or not themes from https://github.com/adi1090x/plymouth-themes + should be enabled and configured. + ''; + + selectedTheme = mkOption { + type = types.str; + default = "bgrt"; + description = '' + Choose which theme to use. + + If you have `myOptions.system.boot.plymouth.withThemes` enabled, you can use more themes from the + https://github.com/adi1090x/plymouth-themes project. You can find the the available theme names at + https://github.com/NixOS/nixpkgs/blob/master/pkgs/data/themes/adi1090x-plymouth-themes/shas.nix. + ''; + }; + }; +} diff --git a/system/boot/default.nix b/system/boot/default.nix index 971ffd6..d6a59b9 100644 --- a/system/boot/default.nix +++ b/system/boot/default.nix @@ -4,5 +4,6 @@ _: { ./generic.nix ./secure-boot.nix ./initrd.nix + ./plymouth.nix ]; } diff --git a/system/boot/plymouth.nix b/system/boot/plymouth.nix new file mode 100644 index 0000000..6cf629f --- /dev/null +++ b/system/boot/plymouth.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ...}: let + inherit (lib) mkIf; + cfg = config.myOptions.system.boot.plymouth; +in { + config = mkIf cfg.enable { + boot.plymouth = { + enable = true; + theme = cfg.selectedTheme; + } + // lib.optionalAttrs cfg.withThemes { + themePackages = [ + (pkgs.adi1090x-plymouth-themes.override { + selected_themes = [ cfg.selectedTheme ]; + }) + ]; + }; + + # Make polymouth work with sleep + powerManagement = { + powerDownCommands = '' + ${pkgs.plymouth} --show-splash + ''; + resumeCommands = '' + ${pkgs.plymouth} --quit + ''; + }; + }; +}