plymouth: use mkTarget (#1631)

Link: https://github.com/nix-community/stylix/pull/1631

Reviewed-by: 1444 <54070204+0x5a4@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
awwpotato 2025-07-08 15:14:50 -07:00 committed by GitHub
parent 0b8ec64a42
commit 1d7a78147d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 48 deletions

View file

@ -1,46 +1,14 @@
{
config,
mkTarget,
pkgs,
lib,
...
}@args:
let
cfg = config.stylix.targets.plymouth;
themeScript = import ./theme-script.nix args;
theme = pkgs.runCommand "stylix-plymouth" { } ''
themeDir="$out/share/plymouth/themes/stylix"
mkdir -p $themeDir
${lib.getExe' pkgs.imagemagick "convert"} \
-background transparent \
-bordercolor transparent \
${
# A transparent border ensures the image is not clipped when rotated
lib.optionalString cfg.logoAnimated "-border 42%"
} \
${cfg.logo} \
$themeDir/logo.png
cp ${themeScript} $themeDir/stylix.script
echo "
[Plymouth Theme]
Name=Stylix
ModuleName=script
[script]
ImageDir=$themeDir
ScriptFile=$themeDir/stylix.script
" > $themeDir/stylix.plymouth
'';
in
{
options.stylix.targets.plymouth = {
enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true;
}:
mkTarget {
name = "plymouth";
humanName = "the Plymouth boot screen";
extraOptions = {
logo = lib.mkOption {
description = "Logo to be used on the boot screen.";
type = with lib.types; either path package;
@ -67,8 +35,42 @@ in
)
];
config.boot.plymouth = lib.mkIf cfg.enable {
theme = "stylix";
themePackages = [ theme ];
};
configElements =
{ cfg, colors }:
let
themeScript = import ./theme-script.nix { inherit lib cfg colors; };
theme = pkgs.runCommand "stylix-plymouth" { } ''
themeDir="$out/share/plymouth/themes/stylix"
mkdir -p $themeDir
${lib.getExe' pkgs.imagemagick "convert"} \
-background transparent \
-bordercolor transparent \
${
# A transparent border ensures the image is not clipped when rotated
lib.optionalString cfg.logoAnimated "-border 42%"
} \
${cfg.logo} \
$themeDir/logo.png
cp ${themeScript} $themeDir/stylix.script
echo "
[Plymouth Theme]
Name=Stylix
ModuleName=script
[script]
ImageDir=$themeDir
ScriptFile=$themeDir/stylix.script
" > $themeDir/stylix.plymouth
'';
in
{
boot.plymouth = {
theme = "stylix";
themePackages = [ theme ];
};
};
}

View file

@ -1,17 +1,15 @@
{
lib,
config,
...
cfg,
colors,
}:
let
cfg = config.stylix.targets.plymouth;
backgroundColor =
with config.lib.stylix.colors;
with colors;
"${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}";
foregroundColor =
with config.lib.stylix.colors;
with colors;
"${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}";
in
builtins.toFile "stylix-plymouth-theme" ''