Merge pull request #162 from thomassdk/FixNixOSSupport

Make splashImage option a `nullOr` type
This commit is contained in:
Vince 2022-03-28 00:26:11 +08:00 committed by GitHub
commit fa74d1b6af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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).
''; '';