From 8ca33835bae0e9158f0a686dbeb139d979943064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 13 Jan 2021 14:02:30 +0100 Subject: [PATCH] nixos: fixup build of aarch64 minimal ISO (fixes #109252) Perhaps it's not pretty nor precise; feel free to improve. --- nixos/modules/installer/cd-dvd/iso-image.nix | 10 ++++++--- nixos/modules/profiles/all-hardware.nix | 22 ++++++++++++++------ nixos/modules/system/boot/kernel.nix | 20 +++++++++++------- nixos/modules/tasks/filesystems/ext.nix | 7 +++++-- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 43d20a556f8d..c2faf5abd842 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -397,6 +397,8 @@ let # Syslinux (and isolinux) only supports x86-based architectures. canx86BiosBoot = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64; + # Some modules apparently aren't present on our aarch64 (and maybe elsewhere). + maybeInitrdModules = lib.optionals (!pkgs.stdenv.hostPlatform.isAarch64); in { @@ -615,9 +617,11 @@ in ]; }; - boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "uas" "overlay" ]; + boot.initrd.availableKernelModules = [ "iso9660" "uas" "overlay" ] + ++ maybeInitrdModules [ "squashfs" ]; - boot.initrd.kernelModules = [ "loop" "overlay" ]; + boot.initrd.kernelModules = [ "overlay" ] + ++ maybeInitrdModules [ "loop" ]; # Closures to be copied to the Nix store on the CD, namely the init # script and the top-level system configuration directory. @@ -716,7 +720,7 @@ in # Add vfat support to the initrd to enable people to copy the # contents of the CD to a bootable USB stick. - boot.initrd.supportedFilesystems = [ "vfat" ]; + boot.initrd.supportedFilesystems = maybeInitrdModules [ "vfat" ]; }; diff --git a/nixos/modules/profiles/all-hardware.nix b/nixos/modules/profiles/all-hardware.nix index 19f821ae17f3..56035f7b6e46 100644 --- a/nixos/modules/profiles/all-hardware.nix +++ b/nixos/modules/profiles/all-hardware.nix @@ -3,20 +3,24 @@ # enabled in the initrd. Its primary use is in the NixOS installation # CDs. -{ ... }: - +{ pkgs, lib,... }: +let + platform = pkgs.stdenv.hostPlatform; +in { # The initrd has to contain any module that might be necessary for # supporting the most important parts of HW like drives. boot.initrd.availableKernelModules = - [ # SATA/PATA support. + # SATA/PATA support. + lib.optionals (!platform.isAarch64) [ # not sure where else they're missing "ahci" - + "sata_sil24" + ] ++ [ "ata_piix" "sata_inic162x" "sata_nv" "sata_promise" "sata_qstor" - "sata_sil" "sata_sil24" "sata_sis" "sata_svw" "sata_sx4" + "sata_sil" "sata_sis" "sata_svw" "sata_sx4" "sata_uli" "sata_via" "sata_vsc" "pata_ali" "pata_amd" "pata_artop" "pata_atiixp" "pata_efar" @@ -38,13 +42,19 @@ # Firewire support. Not tested. "ohci1394" "sbp2" + ] ++ lib.optionals (!platform.isAarch64) [ # not sure where else they're missing # Virtio (QEMU, KVM etc.) support. "virtio_net" "virtio_pci" "virtio_blk" "virtio_scsi" "virtio_balloon" "virtio_console" + ] ++ [ # VMware support. - "mptspi" "vmw_balloon" "vmwgfx" "vmw_vmci" "vmw_vsock_vmci_transport" "vmxnet3" "vsock" + "mptspi" "vmxnet3" "vsock" + ] ++ lib.optionals (!platform.isAarch64) [ # not sure where else they're missing + "vmw_vmci" "vmwgfx" "vmw_vsock_vmci_transport" + ] ++ lib.optional platform.isx86 "vmw_balloon" # Hyper-V support. + ++ lib.optionals (!platform.isAarch64) [ # not sure where else they're missing "hv_storvsc" ]; diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix index ed7226331d70..f391f7ae7662 100644 --- a/nixos/modules/system/boot/kernel.nix +++ b/nixos/modules/system/boot/kernel.nix @@ -194,31 +194,37 @@ in config = mkMerge [ (mkIf config.boot.initrd.enable { - boot.initrd.availableKernelModules = - [ # Note: most of these (especially the SATA/PATA modules) + boot.initrd.availableKernelModules = let + # Some modules apparently aren't present on our aarch64 (and maybe elsewhere). + maybeInitrdModules = lib.optionals (!pkgs.stdenv.hostPlatform.isAarch64); + in + # Note: most of these (especially the SATA/PATA modules) # shouldn't be included by default since nixos-generate-config # detects them, but I'm keeping them for now for backwards # compatibility. # Some SATA/PATA stuff. - "ahci" + maybeInitrdModules [ "ahci" ] + ++ [ "sata_nv" "sata_via" "sata_sis" "sata_uli" "ata_piix" "pata_marvell" + ] # Standard SCSI stuff. - "sd_mod" - "sr_mod" + ++ maybeInitrdModules [ "sd_mod" ] + ++ [ "sr_mod" ] # SD cards and internal eMMC drives. - "mmc_block" + ++ maybeInitrdModules [ "mmc_block" ] # Support USB keyboards, in case the boot fails and we only have # a USB keyboard, or for LUKS passphrase prompt. - "uhci_hcd" + ++ [ "uhci_hcd" ] + ++ maybeInitrdModules [ "ehci_hcd" "ehci_pci" "ohci_hcd" diff --git a/nixos/modules/tasks/filesystems/ext.nix b/nixos/modules/tasks/filesystems/ext.nix index a14a3ac38549..67f6d00ae5c9 100644 --- a/nixos/modules/tasks/filesystems/ext.nix +++ b/nixos/modules/tasks/filesystems/ext.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { config = { @@ -6,7 +6,10 @@ system.fsPackages = [ pkgs.e2fsprogs ]; # As of kernel 4.3, there is no separate ext3 driver (they're also handled by ext4.ko) - boot.initrd.availableKernelModules = [ "ext2" "ext4" ]; + # No ext* modules are present on our aarch64, apparently (and maybe elsewhere). + boot.initrd.availableKernelModules = + lib.optionals (!pkgs.stdenv.hostPlatform.isAarch64) + [ "ext2" "ext4" ]; boot.initrd.extraUtilsCommands = ''