mirror of
https://github.com/vinceliuice/grub2-themes.git
synced 2024-11-05 17:16:14 +01:00
Merge branch 'master' of github.com:vinceliuice/grub2-themes
This commit is contained in:
commit
8a5ebe97fa
72
flake.nix
72
flake.nix
@ -14,10 +14,12 @@
|
|||||||
in
|
in
|
||||||
with nixpkgs.lib;
|
with nixpkgs.lib;
|
||||||
rec {
|
rec {
|
||||||
nixosModule = { config, ... }:
|
nixosModules.default = { config, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.boot.loader.grub2-theme;
|
cfg = config.boot.loader.grub2-theme;
|
||||||
splashImage = if cfg.splashImage == null then "" else cfg.splashImage;
|
splashImage = if cfg.splashImage == null then "" else cfg.splashImage;
|
||||||
|
hasBootMenuConfig = cfg.bootMenuConfig != null;
|
||||||
|
hasTerminalConfig = cfg.terminalConfig != null;
|
||||||
resolutions = {
|
resolutions = {
|
||||||
"1080p" = "1920x1080";
|
"1080p" = "1920x1080";
|
||||||
"ultrawide" = "2560x1080";
|
"ultrawide" = "2560x1080";
|
||||||
@ -37,11 +39,30 @@
|
|||||||
--icon ${cfg.icon};
|
--icon ${cfg.icon};
|
||||||
|
|
||||||
if [ -n "${splashImage}" ]; then
|
if [ -n "${splashImage}" ]; then
|
||||||
cp ${splashImage} $out/grub/themes/${cfg.theme}/background.jpg;
|
filename=$(basename -- "${splashImage}")
|
||||||
|
extension="''${filename##*.}"
|
||||||
|
rm $out/grub/themes/${cfg.theme}/background.jpg;
|
||||||
|
cp ${splashImage} $out/grub/themes/${cfg.theme}/background.$extension;
|
||||||
|
cp ${splashImage} $out/grub/themes/${cfg.theme}/background;
|
||||||
|
sed -i "s/background.jpg/background.$extension/g" $out/grub/themes/${cfg.theme}/theme.txt;
|
||||||
fi;
|
fi;
|
||||||
if [ ${pkgs.lib.trivial.boolToString cfg.footer} == "false" ]; then
|
if [ ${pkgs.lib.trivial.boolToString cfg.footer} == "false" ]; then
|
||||||
sed -i ':again;$!N;$!b again; s/\+ image {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt;
|
sed -i ':again;$!N;$!b again; s/\+ image {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt;
|
||||||
fi;
|
fi;
|
||||||
|
if [ ${pkgs.lib.trivial.boolToString hasBootMenuConfig} == "true" ]; then
|
||||||
|
sed -i ':again;$!N;$!b again; s/\+ boot_menu {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt;
|
||||||
|
cat << EOF >> $out/grub/themes/${cfg.theme}/theme.txt
|
||||||
|
+ boot_menu {
|
||||||
|
${if cfg.bootMenuConfig == null then "" else cfg.bootMenuConfig}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi;
|
||||||
|
if [ ${pkgs.lib.trivial.boolToString hasTerminalConfig} == "true" ]; then
|
||||||
|
sed -i 's/^terminal-.*$//g' $out/grub/themes/${cfg.theme}/theme.txt
|
||||||
|
cat << EOF >> $out/grub/themes/${cfg.theme}/theme.txt
|
||||||
|
${if cfg.terminalConfig == null then "" else cfg.terminalConfig}
|
||||||
|
EOF
|
||||||
|
fi;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
resolution = resolutions."${cfg.screen}";
|
resolution = resolutions."${cfg.screen}";
|
||||||
@ -86,7 +107,25 @@
|
|||||||
example = "/my/path/background.jpg";
|
example = "/my/path/background.jpg";
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr types.path;
|
||||||
description = ''
|
description = ''
|
||||||
The path of the image to use for background (must be jpg).
|
The path of the image to use for background (must be jpg or png).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
bootMenuConfig = mkOption {
|
||||||
|
default = null;
|
||||||
|
example = "left = 30%";
|
||||||
|
type = types.nullOr types.string;
|
||||||
|
description = ''
|
||||||
|
Grub theme definition for boot_menu.
|
||||||
|
Refer to config/theme-*.txt for reference.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
terminalConfig = mkOption {
|
||||||
|
default = null;
|
||||||
|
example = "terminal-font: \"Terminus Regular 18\"";
|
||||||
|
type = types.nullOr types.string;
|
||||||
|
description = ''
|
||||||
|
Replaces grub theme definition for terminial-*.
|
||||||
|
Refer to config/theme-*.txt for reference.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
footer = mkOption {
|
footer = mkOption {
|
||||||
@ -103,17 +142,22 @@
|
|||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
grub2-theme
|
grub2-theme
|
||||||
];
|
];
|
||||||
boot.loader.grub = {
|
boot.loader.grub =
|
||||||
theme = "${grub2-theme}/grub/themes/${cfg.theme}";
|
let
|
||||||
splashImage = "${grub2-theme}/grub/themes/${cfg.theme}/background.jpg";
|
ext = if cfg.splashImage == null then "jpg" else last (splitString "." cfg.splashImage);
|
||||||
gfxmodeEfi = "${resolution},auto";
|
in
|
||||||
gfxmodeBios = "${resolution},auto";
|
{
|
||||||
extraConfig = ''
|
theme = "${grub2-theme}/grub/themes/${cfg.theme}";
|
||||||
insmod gfxterm
|
splashImage =
|
||||||
insmod png
|
"${grub2-theme}/grub/themes/${cfg.theme}/background.${ext}";
|
||||||
set icondir=($root)/theme/icons
|
gfxmodeEfi = "${resolution},auto";
|
||||||
'';
|
gfxmodeBios = "${resolution},auto";
|
||||||
};
|
extraConfig = ''
|
||||||
|
insmod gfxterm
|
||||||
|
insmod png
|
||||||
|
set icondir=($root)/theme/icons
|
||||||
|
'';
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user