grub: migrate to mkTarget#2357
Conversation
0xda157
commented
Jun 5, 2026
- I certify that I have the right to submit this contribution under the MIT license
- Commit messages adhere to Stylix commit conventions
- Theming changes adhere to the Stylix style guide
- Changes have been tested locally
- Changes have been tested in testbeds
- Each commit in this PR is suitable for backport
|
(marking as draft until I can test locally) |
| stylix.targets.grub.theme = { | ||
| main = '' |
There was a problem hiding this comment.
Nitpick:
| stylix.targets.grub.theme = { | |
| main = '' | |
| stylix.targets.grub.theme.main = '' |
| stylix.targets.grub.theme = { | ||
| main = '' | ||
| desktop-color: "${colors.withHashtag.base00}" | ||
| ''; | ||
| }; |
There was a problem hiding this comment.
If the surrounding newlines are optional, this could be simplified as something like:
| stylix.targets.grub.theme = { | |
| main = '' | |
| desktop-color: "${colors.withHashtag.base00}" | |
| ''; | |
| }; | |
| stylix.targets.grub.theme.main = | |
| ''desktop-color: "${colors.withHashtag.base00}"''; |
| { | ||
| mkTarget { | ||
| options = { | ||
| useWallpaper = mkEnableWallpaper "GRUB" false; |
There was a problem hiding this comment.
|
|
||
|
|
There was a problem hiding this comment.
Remove the noisy empty lines:
diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix
index 93195cd7..7cd1d2e7 100644
--- a/modules/grub/nixos.nix
+++ b/modules/grub/nixos.nix
@@ -172,8 +172,6 @@ mkTarget {
desktop-image-scale-method: "${image-scale}"
'';
extraBuildScript = ''
-
-
${
if
cfg.useWallpaper| # This font will be used for the GRUB terminal | ||
| font = toString (mkGrubFont fonts.monospace); | ||
|
|
||
| # TODO: Include OS icons |
There was a problem hiding this comment.
This vanished comment should probably be brought back.
| || cfg.theme.boot_menu != "" | ||
| ) | ||
| { | ||
|
|
There was a problem hiding this comment.
diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix
index 93195cd7..65a1cf79 100644
--- a/modules/grub/nixos.nix
+++ b/modules/grub/nixos.nix
@@ -63,7 +63,6 @@ mkTarget {
|| cfg.theme.boot_menu != ""
)
{
-
theme =
pkgs.runCommand "stylix-grub"
{| lib.mkIf | ||
| ( | ||
| cfg.theme.main != "" | ||
| || cfg.theme.progress_bar != "" | ||
| || cfg.theme.boot_menu != "" | ||
| ) |
There was a problem hiding this comment.
Should we not move this lib.mkIf into the single theme declaration:
theme =
lib.mkIf
(
/* ... */
)
(
pkgs.runCommand "stylix-grub"
{
/* ... */
}
(
/* ... */
)
);| cfg.theme.main != "" | ||
| || cfg.theme.progress_bar != "" | ||
| || cfg.theme.boot_menu != "" |
There was a problem hiding this comment.
If the purpose of this clever condition is to only declare the otherwise unconditional Stylix theme when something of value happens, should it not guard on everything, including cfg.theme.extraBuildScript:
| cfg.theme.main != "" | |
| || cfg.theme.progress_bar != "" | |
| || cfg.theme.boot_menu != "" | |
| cfg.theme.main != "" | |
| || cfg.theme.progress_bar != "" | |
| || cfg.theme.boot_menu != "" | |
| || cfg.theme.extraBuildScript != "" |
| pkgs.runCommand "stylix-grub" | ||
| { | ||
| passAsFile = [ "themeTxt" ]; | ||
| themeTxt = '' |
There was a problem hiding this comment.
IMHO, this looks better without explicitly concatenating strings:
diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix
index 93195cd7..a32c783c 100644
--- a/modules/grub/nixos.nix
+++ b/modules/grub/nixos.nix
@@ -77,36 +77,38 @@ mkTarget {
terminal-height: "60%"
${cfg.theme.main}
- ''
- + lib.optionalString (cfg.theme.progress_bar != "") ''
- + progress_bar {
- left = 25%
- top = 80%+20 # 20 pixels below boot menu
- width = 50%
- height = 30
- id = "__timeout__"
- show_text = true
- text = "@TIMEOUT_NOTIFICATION_MIDDLE@"
- ${cfg.theme.progress_bar}
- }
- ''
- + lib.optionalString (cfg.theme.boot_menu != "") ''
- + boot_menu {
- left = 25%
- top = 20%
- width = 50%
- height = 60%
- menu_pixmap_style = "background_*.png"
+ ${lib.optionalString (cfg.theme.progress_bar != "") ''
+ + progress_bar {
+ left = 25%
+ top = 80%+20 # 20 pixels below boot menu
+ width = 50%
+ height = 30
+
+ id = "__timeout__"
+ show_text = true
+ text = "@TIMEOUT_NOTIFICATION_MIDDLE@"
+ ${cfg.theme.progress_bar}
+ }
+ ''}
+
+ ${lib.optionalString (cfg.theme.boot_menu != "") ''
+ + boot_menu {
+ left = 25%
+ top = 20%
+ width = 50%
+ height = 60%
+ menu_pixmap_style = "background_*.png"
- item_height = 40
- item_icon_space = 8
- item_spacing = 0
- item_padding = 0
+ item_height = 40
+ item_icon_space = 8
+ item_spacing = 0
+ item_padding = 0
- selected_item_pixmap_style = "selection_*.png"
- ${cfg.theme.boot_menu}
- }
+ selected_item_pixmap_style = "selection_*.png"
+ ${cfg.theme.boot_menu}
+ }
+ ''}
'';
}
(| ( | ||
| '' | ||
| mkdir $out | ||
| cp $themeTxtPath $out/theme.txt | ||
| '' | ||
| + cfg.theme.extraBuildScript | ||
| ); |
There was a problem hiding this comment.
IMHO, this looks better without explicitly concatenating strings:
diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix
index 93195cd7..d4047b66 100644
--- a/modules/grub/nixos.nix
+++ b/modules/grub/nixos.nix
@@ -109,13 +109,12 @@ mkTarget {
}
'';
}
- (
- ''
- mkdir $out
- cp $themeTxtPath $out/theme.txt
- ''
- + cfg.theme.extraBuildScript
- );
+ ''
+ mkdir $out
+ cp $themeTxtPath $out/theme.txt
+
+ ${cfg.theme.extraBuildScript}
+ '';
}
)
(