mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 14:22:50 +03:00
Merge pull request #233518 from tie/bios-bootable-x86
nixos/iso-image: enable BIOS boot by default if possible
This commit is contained in:
commit
0d13962366
@ -21,9 +21,6 @@ with lib;
|
|||||||
# ISO naming.
|
# ISO naming.
|
||||||
isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.iso";
|
isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.iso";
|
||||||
|
|
||||||
# BIOS booting
|
|
||||||
isoImage.makeBiosBootable = true;
|
|
||||||
|
|
||||||
# EFI booting
|
# EFI booting
|
||||||
isoImage.makeEfiBootable = true;
|
isoImage.makeEfiBootable = true;
|
||||||
|
|
||||||
|
@ -442,9 +442,6 @@ let
|
|||||||
fsck.vfat -vn "$out"
|
fsck.vfat -vn "$out"
|
||||||
''; # */
|
''; # */
|
||||||
|
|
||||||
# Syslinux (and isolinux) only supports x86-based architectures.
|
|
||||||
canx86BiosBoot = pkgs.stdenv.hostPlatform.isx86;
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -543,7 +540,17 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
isoImage.makeBiosBootable = mkOption {
|
isoImage.makeBiosBootable = mkOption {
|
||||||
default = false;
|
# Before this option was introduced, images were BIOS-bootable if the
|
||||||
|
# hostPlatform was x86-based. This option is enabled by default for
|
||||||
|
# backwards compatibility.
|
||||||
|
#
|
||||||
|
# Also note that syslinux package currently cannot be cross-compiled from
|
||||||
|
# non-x86 platforms, so the default is false on non-x86 build platforms.
|
||||||
|
default = pkgs.stdenv.buildPlatform.isx86 && pkgs.stdenv.hostPlatform.isx86;
|
||||||
|
defaultText = lib.literalMD ''
|
||||||
|
`true` if both build and host platforms are x86-based architectures,
|
||||||
|
e.g. i686 and x86_64.
|
||||||
|
'';
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Whether the ISO image should be a BIOS-bootable disk.
|
Whether the ISO image should be a BIOS-bootable disk.
|
||||||
@ -704,6 +711,11 @@ in
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
assertions = [
|
assertions = [
|
||||||
|
{
|
||||||
|
# Syslinux (and isolinux) only supports x86-based architectures.
|
||||||
|
assertion = config.isoImage.makeBiosBootable -> pkgs.stdenv.hostPlatform.isx86;
|
||||||
|
message = "BIOS boot is only supported on x86-based architectures.";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
assertion = !(stringLength config.isoImage.volumeID > 32);
|
assertion = !(stringLength config.isoImage.volumeID > 32);
|
||||||
# https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
|
# https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
|
||||||
@ -722,7 +734,7 @@ in
|
|||||||
boot.loader.grub.enable = false;
|
boot.loader.grub.enable = false;
|
||||||
|
|
||||||
environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ]
|
environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ]
|
||||||
++ optional (config.isoImage.makeBiosBootable && canx86BiosBoot) pkgs.syslinux
|
++ optional (config.isoImage.makeBiosBootable) pkgs.syslinux
|
||||||
;
|
;
|
||||||
|
|
||||||
# In stage 1 of the boot, mount the CD as the root FS by label so
|
# In stage 1 of the boot, mount the CD as the root FS by label so
|
||||||
@ -773,7 +785,7 @@ in
|
|||||||
{ source = pkgs.writeText "version" config.system.nixos.label;
|
{ source = pkgs.writeText "version" config.system.nixos.label;
|
||||||
target = "/version.txt";
|
target = "/version.txt";
|
||||||
}
|
}
|
||||||
] ++ optionals (config.isoImage.makeBiosBootable && canx86BiosBoot) [
|
] ++ optionals (config.isoImage.makeBiosBootable) [
|
||||||
{ source = config.isoImage.splashImage;
|
{ source = config.isoImage.splashImage;
|
||||||
target = "/isolinux/background.png";
|
target = "/isolinux/background.png";
|
||||||
}
|
}
|
||||||
@ -800,7 +812,7 @@ in
|
|||||||
{ source = config.isoImage.efiSplashImage;
|
{ source = config.isoImage.efiSplashImage;
|
||||||
target = "/EFI/boot/efi-background.png";
|
target = "/EFI/boot/efi-background.png";
|
||||||
}
|
}
|
||||||
] ++ optionals (config.boot.loader.grub.memtest86.enable && config.isoImage.makeBiosBootable && canx86BiosBoot) [
|
] ++ optionals (config.boot.loader.grub.memtest86.enable && config.isoImage.makeBiosBootable) [
|
||||||
{ source = "${pkgs.memtest86plus}/memtest.bin";
|
{ source = "${pkgs.memtest86plus}/memtest.bin";
|
||||||
target = "/boot/memtest.bin";
|
target = "/boot/memtest.bin";
|
||||||
}
|
}
|
||||||
@ -815,10 +827,10 @@ in
|
|||||||
# Create the ISO image.
|
# Create the ISO image.
|
||||||
system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({
|
system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({
|
||||||
inherit (config.isoImage) isoName compressImage volumeID contents;
|
inherit (config.isoImage) isoName compressImage volumeID contents;
|
||||||
bootable = config.isoImage.makeBiosBootable && canx86BiosBoot;
|
bootable = config.isoImage.makeBiosBootable;
|
||||||
bootImage = "/isolinux/isolinux.bin";
|
bootImage = "/isolinux/isolinux.bin";
|
||||||
syslinux = if config.isoImage.makeBiosBootable && canx86BiosBoot then pkgs.syslinux else null;
|
syslinux = if config.isoImage.makeBiosBootable then pkgs.syslinux else null;
|
||||||
} // optionalAttrs (config.isoImage.makeUsbBootable && config.isoImage.makeBiosBootable && canx86BiosBoot) {
|
} // optionalAttrs (config.isoImage.makeUsbBootable && config.isoImage.makeBiosBootable) {
|
||||||
usbBootable = true;
|
usbBootable = true;
|
||||||
isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
|
isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
|
||||||
} // optionalAttrs config.isoImage.makeEfiBootable {
|
} // optionalAttrs config.isoImage.makeEfiBootable {
|
||||||
|
Loading…
Reference in New Issue
Block a user