From 53884e1b94efe183ef6d32758a9f7ceee4aa0b19 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 1 Jun 2019 21:14:05 -0400 Subject: [PATCH] sd-image: Switch /boot to the ext4 partition --- .../modules/installer/cd-dvd/sd-image-aarch64.nix | 5 ++++- .../cd-dvd/sd-image-armv7l-multiplatform.nix | 5 ++++- .../installer/cd-dvd/sd-image-raspberrypi.nix | 5 ++++- nixos/modules/installer/cd-dvd/sd-image.nix | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix index eb0bc9da409..49008bef834 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix @@ -46,7 +46,10 @@ in (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/) cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin cp ${configTxt} firmware/config.txt - ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./firmware ''; + populateRootCommands = '' + mkdir -p ./files/boot + ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot + ''; }; } diff --git a/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix b/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix index 02587ba4af0..dab09241531 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix @@ -50,7 +50,10 @@ in cp ${pkgs.ubootRaspberryPi2}/u-boot.bin firmware/u-boot-rpi2.bin cp ${pkgs.ubootRaspberryPi3_32bit}/u-boot.bin firmware/u-boot-rpi3.bin cp ${configTxt} firmware/config.txt - ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./firmware ''; + populateRootCommands = '' + mkdir -p ./files/boot + ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot + ''; }; } diff --git a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix index de3385290d2..cb78bbafecf 100644 --- a/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix +++ b/nixos/modules/installer/cd-dvd/sd-image-raspberrypi.nix @@ -39,7 +39,10 @@ in cp ${pkgs.ubootRaspberryPiZero}/u-boot.bin firmware/u-boot-rpi0.bin cp ${pkgs.ubootRaspberryPi}/u-boot.bin firmware/u-boot-rpi1.bin cp ${configTxt} firmware/config.txt - ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./firmware ''; + populateRootCommands = '' + mkdir -p ./files/boot + ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot + ''; }; } diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix index 6b5bccfa2e7..387af9373f4 100644 --- a/nixos/modules/installer/cd-dvd/sd-image.nix +++ b/nixos/modules/installer/cd-dvd/sd-image.nix @@ -14,6 +14,7 @@ with lib; let rootfsImage = pkgs.callPackage ../../../lib/make-ext4-fs.nix ({ inherit (config.sdImage) storePaths; + populateImageCommands = config.sdImage.populateRootCommands; volumeLabel = "NIXOS_SD"; } // optionalAttrs (config.sdImage.rootPartitionUUID != null) { uuid = config.sdImage.rootPartitionUUID; @@ -77,6 +78,16 @@ in /boot/firmware partition on the SD image. ''; }; + + populateRootCommands = mkOption { + example = literalExample "''\${extlinux-conf-builder} -t 3 -c \${config.system.build.toplevel} -d ./files/boot''"; + description = '' + Shell commands to populate the ./files directory. + All files in that directory are copied to the + root (/) partition on the SD image. Use this to + populate the ./files/boot (/boot) directory. + ''; + }; }; config = { @@ -117,8 +128,8 @@ in label: dos label-id: ${config.sdImage.firmwarePartitionID} - start=8M, size=$firmwareSizeBlocks, type=b, bootable - start=${toString (8 + config.sdImage.firmwareSize)}M, type=83 + start=8M, size=$firmwareSizeBlocks, type=b + start=${toString (8 + config.sdImage.firmwareSize)}M, type=83, bootable EOF # Copy the rootfs into the SD image