Skip to content

Commit 1d7a781

Browse files
authored
plymouth: use mkTarget (#1631)
Link: #1631 Reviewed-by: 1444 <[email protected]> Reviewed-by: NAHO <[email protected]>
1 parent 0b8ec64 commit 1d7a781

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

modules/plymouth/nixos.nix

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,14 @@
11
{
2-
config,
2+
mkTarget,
33
pkgs,
44
lib,
55
...
6-
}@args:
7-
8-
let
9-
cfg = config.stylix.targets.plymouth;
10-
11-
themeScript = import ./theme-script.nix args;
12-
13-
theme = pkgs.runCommand "stylix-plymouth" { } ''
14-
themeDir="$out/share/plymouth/themes/stylix"
15-
mkdir -p $themeDir
16-
17-
${lib.getExe' pkgs.imagemagick "convert"} \
18-
-background transparent \
19-
-bordercolor transparent \
20-
${
21-
# A transparent border ensures the image is not clipped when rotated
22-
lib.optionalString cfg.logoAnimated "-border 42%"
23-
} \
24-
${cfg.logo} \
25-
$themeDir/logo.png
26-
27-
cp ${themeScript} $themeDir/stylix.script
28-
29-
echo "
30-
[Plymouth Theme]
31-
Name=Stylix
32-
ModuleName=script
33-
34-
[script]
35-
ImageDir=$themeDir
36-
ScriptFile=$themeDir/stylix.script
37-
" > $themeDir/stylix.plymouth
38-
'';
39-
in
40-
{
41-
options.stylix.targets.plymouth = {
42-
enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true;
6+
}:
7+
mkTarget {
8+
name = "plymouth";
9+
humanName = "the Plymouth boot screen";
4310

11+
extraOptions = {
4412
logo = lib.mkOption {
4513
description = "Logo to be used on the boot screen.";
4614
type = with lib.types; either path package;
@@ -67,8 +35,42 @@ in
6735
)
6836
];
6937

70-
config.boot.plymouth = lib.mkIf cfg.enable {
71-
theme = "stylix";
72-
themePackages = [ theme ];
73-
};
38+
configElements =
39+
{ cfg, colors }:
40+
let
41+
themeScript = import ./theme-script.nix { inherit lib cfg colors; };
42+
43+
theme = pkgs.runCommand "stylix-plymouth" { } ''
44+
themeDir="$out/share/plymouth/themes/stylix"
45+
mkdir -p $themeDir
46+
47+
${lib.getExe' pkgs.imagemagick "convert"} \
48+
-background transparent \
49+
-bordercolor transparent \
50+
${
51+
# A transparent border ensures the image is not clipped when rotated
52+
lib.optionalString cfg.logoAnimated "-border 42%"
53+
} \
54+
${cfg.logo} \
55+
$themeDir/logo.png
56+
57+
cp ${themeScript} $themeDir/stylix.script
58+
59+
echo "
60+
[Plymouth Theme]
61+
Name=Stylix
62+
ModuleName=script
63+
64+
[script]
65+
ImageDir=$themeDir
66+
ScriptFile=$themeDir/stylix.script
67+
" > $themeDir/stylix.plymouth
68+
'';
69+
in
70+
{
71+
boot.plymouth = {
72+
theme = "stylix";
73+
themePackages = [ theme ];
74+
};
75+
};
7476
}

modules/plymouth/theme-script.nix

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
{
22
lib,
3-
config,
4-
...
3+
cfg,
4+
colors,
55
}:
66
let
7-
cfg = config.stylix.targets.plymouth;
8-
97
backgroundColor =
10-
with config.lib.stylix.colors;
8+
with colors;
119
"${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}";
1210

1311
foregroundColor =
14-
with config.lib.stylix.colors;
12+
with colors;
1513
"${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}";
1614
in
1715
builtins.toFile "stylix-plymouth-theme" ''

0 commit comments

Comments
 (0)