summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2018-05-23 21:36:06 -0400
committerGitHub <noreply@github.com>2018-05-23 21:36:06 -0400
commit290505bf1bb8e4aa65e07b6eaf1b455439b56e25 (patch)
treec1f0ebaaeb04e1e63bc7855003e02eb2bd9276bc /nixos
parent6980edf2ba7135a855d12479b25fa4686b5adc25 (diff)
parent0ccfe14e25771d83460305ee09d99cb449eea15a (diff)
downloadnixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar.gz
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar.bz2
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar.lz
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar.xz
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.tar.zst
nixpkgs-290505bf1bb8e4aa65e07b6eaf1b455439b56e25.zip
Merge pull request #40462 from samueldr/fix/grub-background
Fixes grub splashImage documentation + implementation
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/loader/grub/grub.nix18
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl14
2 files changed, 24 insertions, 8 deletions
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix
index e2cff1c1bd9..67daaa333e5 100644
--- a/nixos/modules/system/boot/loader/grub/grub.nix
+++ b/nixos/modules/system/boot/loader/grub/grub.nix
@@ -308,10 +308,22 @@ in
         type = types.nullOr types.path;
         example = literalExample "./my-background.png";
         description = ''
-          Background image used for GRUB.  It must be a 640x480,
+          Background image used for GRUB.
+          Set to <literal>null</literal> to run GRUB in text mode.
+
+          <note><para>
+          For grub 1:
+          It must be a 640x480,
           14-colour image in XPM format, optionally compressed with
-          <command>gzip</command> or <command>bzip2</command>.  Set to
-          <literal>null</literal> to run GRUB in text mode.
+          <command>gzip</command> or <command>bzip2</command>.
+          </para></note>
+
+          <note><para>
+          For grub 2:
+          File must be one of .png, .tga, .jpg, or .jpeg. JPEG images must
+          not be progressive.
+          The image will be scaled if necessary to fit the screen.
+          </para></note>
         '';
       };
 
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index 8bd203106f5..1aa14729a75 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -299,12 +299,16 @@ else {
         copy $font, "$bootPath/converted-font.pf2" or die "cannot copy $font to $bootPath\n";
     }
     if ($splashImage) {
-        # FIXME: GRUB 1.97 doesn't resize the background image if it
-        # doesn't match the video resolution.
-        copy $splashImage, "$bootPath/background.png" or die "cannot copy $splashImage to $bootPath\n";
+        # Keeps the image's extension.
+        my ($filename, $dirs, $suffix) = fileparse($splashImage, qr"\..[^.]*$");
+        # The module for jpg is jpeg.
+        if ($suffix eq ".jpg") {
+            $suffix = ".jpeg";
+        }
+        copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath\n";
         $conf .= "
-            insmod png
-            if background_image " . $grubBoot->path . "/background.png; then
+            insmod " . substr($suffix, 1) . "
+            if background_image " . $grubBoot->path . "/background$suffix; then
               set color_normal=white/black
               set color_highlight=black/white
             else