From 37e50ca63513072d7024a3c44500684b4f2e032b Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 10 Jun 2020 21:17:09 -0400 Subject: [PATCH 1/3] raspberrypi-builder: ensure scripts fails on error The way this ends up being called with the raspberry pi 4 image builder ends up not using the `-e` from the shebang. In turn, the builds fails during cross-compilation. The wrong coreutils ends up being used, but this is not made apparent. The issue I faced is already fixed on master, but this ensures no one ends up with a failed build "succeeding". --- .../system/boot/loader/raspberrypi/raspberrypi-builder.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh index c8b5bf2e61a..0541ca1ba62 100644 --- a/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh +++ b/nixos/modules/system/boot/loader/raspberrypi/raspberrypi-builder.sh @@ -1,4 +1,7 @@ -#! @bash@/bin/sh -e +#! @bash@/bin/sh + +# This can end up being called disregarding the shebang. +set -e shopt -s nullglob From 34caab71bbd2ae342c65667cc999a3be8a1ad336 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 10 Jun 2020 21:30:22 -0400 Subject: [PATCH 2/3] sd-image: Make firmware partition name configurable This will be helpful in the now too-long-lived image for the Raspberry Pi 4. We'll be able to properly configure the partition to be useful. --- nixos/modules/installer/cd-dvd/sd-image.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix index 589bf74263b..d0ef55bd0e1 100644 --- a/nixos/modules/installer/cd-dvd/sd-image.nix +++ b/nixos/modules/installer/cd-dvd/sd-image.nix @@ -63,6 +63,14 @@ in ''; }; + firmwarePartitionName = mkOption { + type = types.str; + default = "FIRMWARE"; + description = '' + Name of the filesystem which holds the boot firmware. + ''; + }; + rootPartitionUUID = mkOption { type = types.nullOr types.str; default = null; @@ -114,7 +122,7 @@ in config = { fileSystems = { "/boot/firmware" = { - device = "/dev/disk/by-label/FIRMWARE"; + device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; fsType = "vfat"; # Alternatively, this could be removed from the configuration. # The filesystem is not needed at runtime, it could be treated @@ -178,7 +186,7 @@ in # Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img eval $(partx $img -o START,SECTORS --nr 1 --pairs) truncate -s $((SECTORS * 512)) firmware_part.img - faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n FIRMWARE firmware_part.img + faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img # Populate the files intended for /boot/firmware mkdir firmware From 476c8e0754968cc0d56479894ea5c3037dd70892 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 10 Jun 2020 23:32:06 -0400 Subject: [PATCH 3/3] sd-image-raspberrypi4: mount boot partition This should have been done initially, as otherwise it gets awfully awkward to boot into new generations by default. This system-specific image wasn't expected to be long-lived, thus why it didn't end up being polished much. Reality shows us we may be stuck with it for a bit longer, so let's make it easier to use for new users. --- nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix index c545a1e7e24..79c835dc390 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi4.nix @@ -18,6 +18,7 @@ sdImage = { firmwareSize = 128; + firmwarePartitionName = "NIXOS_BOOT"; # This is a hack to avoid replicating config.txt from boot.loader.raspberryPi populateFirmwareCommands = "${config.system.build.installBootLoader} ${config.system.build.toplevel} -d ./firmware"; @@ -25,6 +26,12 @@ populateRootCommands = ""; }; + fileSystems."/boot/firmware" = { + # This effectively "renames" the loaOf entry set in sd-image.nix + mountPoint = "/boot"; + neededForBoot = true; + }; + # the installation media is also the installation target, # so we don't want to provide the installation configuration.nix. installer.cloneConfig = false;