Make splashImage option a nullOr type

This commit is contained in:
thomassdk 2022-03-27 15:52:59 +00:00
parent 20a8f12488
commit 29dd80dd70

View file

@ -17,6 +17,7 @@
nixosModule = { config, ... }: nixosModule = { config, ... }:
let let
cfg = config.boot.loader.grub2-theme; cfg = config.boot.loader.grub2-theme;
splashImage = if cfg.splashImage == null then "" else cfg.splashImage;
resolutions = { resolutions = {
"1080p" = "1920x1080"; "1080p" = "1920x1080";
"ultrawide" = "2560x1080"; "ultrawide" = "2560x1080";
@ -35,8 +36,8 @@
--theme ${cfg.theme} \ --theme ${cfg.theme} \
--icon ${cfg.icon}; --icon ${cfg.icon};
if [ -f ${cfg.splashImage} ]; then if [ -n "${splashImage}" ]; then
cp ${cfg.splashImage} $out/grub/themes/${cfg.theme}/background.jpg; cp ${splashImage} $out/grub/themes/${cfg.theme}/background.jpg;
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;
@ -81,9 +82,9 @@
''; '';
}; };
splashImage = mkOption { splashImage = mkOption {
default = ""; default = null;
example = "/my/path/background.jpg"; example = "/my/path/background.jpg";
type = 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).
''; '';