From 4f3b99cdf3900f7f5fd396f92b256ddfd90ec646 Mon Sep 17 00:00:00 2001 From: madisetti Date: Mon, 21 Feb 2022 11:59:04 -0500 Subject: [PATCH] Added footer and enable option --- flake.nix | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 0fbada7..5079697 100644 --- a/flake.nix +++ b/flake.nix @@ -34,6 +34,13 @@ --screen ${cfg.screen} \ --theme ${cfg.theme} \ --icon ${cfg.icon}; + + if [ -f ${cfg.splashImage} ]; then + cp ${cfg.splashImage} $out/grub/themes/${cfg.theme}/background.jpg; + fi; + 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; + fi; ''; }; resolution = resolutions."${cfg.screen}"; @@ -41,6 +48,14 @@ rec { options = { boot.loader.grub2-theme = { + enable = mkOption { + default = true; + example = true; + type = types.bool; + description = '' + Enable grub2 theming + ''; + }; theme = mkOption { default = "tela"; example = "tela"; @@ -68,14 +83,22 @@ splashImage = mkOption { default = ""; example = "/my/path/background.jpg"; - type = types.string; + type = types.path; description = '' The path of the image to use for background (must be jpg). ''; }; + footer = mkOption { + default = true; + example = true; + type = types.bool; + description = '' + Whether to include the image footer. + ''; + }; }; }; - config = mkMerge [{ + config = mkIf cfg.enable (mkMerge [{ environment.systemPackages = [ grub2-theme ]; @@ -84,8 +107,13 @@ splashImage = "${grub2-theme}/grub/themes/${cfg.theme}/background.jpg"; gfxmodeEfi = "${resolution},auto"; gfxmodeBios = "${resolution},auto"; + extraConfig = '' + insmod gfxterm + insmod png + set icondir=($root)/theme/icons + ''; }; - }]; + }]); }; }; }