Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit beb01f0

Browse files
committed
add firmware-partition-label option
1 parent 61d43e9 commit beb01f0

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

rpi/default.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ in
2626
without the _defconfig part.
2727
'';
2828
};
29+
firmware-partition-label = mkOption {
30+
default = "FIRMWARE";
31+
type = types.str;
32+
description = "label of rpi firmware partition";
33+
};
2934
pin-inputs = {
3035
enable = mkOption {
3136
default = true;
@@ -94,7 +99,7 @@ in
9499
{
95100
Type = "oneshot";
96101
MountImages =
97-
"/dev/disk/by-label/FIRMWARE:${firmware-path}";
102+
"/dev/disk/by-label/${cfg.firmware-partition-label}:${firmware-path}";
98103
StateDirectory = "raspberrypi-firmware";
99104
ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" ''
100105
shopt -s nullglob

sd-image/sd-image.nix

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ let
3030
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
3131
uuid = config.sdImage.rootPartitionUUID;
3232
});
33-
in {
33+
in
34+
{
3435
imports = [ ];
3536

3637
options.sdImage = {
@@ -82,14 +83,6 @@ in {
8283
'';
8384
};
8485

85-
firmwarePartitionName = mkOption {
86-
type = types.str;
87-
default = "FIRMWARE";
88-
description = ''
89-
Name of the filesystem which holds the boot firmware.
90-
'';
91-
};
92-
9386
rootPartitionUUID = mkOption {
9487
type = types.nullOr types.str;
9588
default = null;
@@ -160,7 +153,7 @@ in {
160153
config = {
161154
fileSystems = {
162155
"/boot/firmware" = {
163-
device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}";
156+
device = "/dev/disk/by-label/${config.raspberry-pi-nix.firmware-partition-label}";
164157
fsType = "vfat";
165158
};
166159
"/" = {
@@ -226,7 +219,7 @@ in {
226219
# Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
227220
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
228221
truncate -s $((SECTORS * 512)) firmware_part.img
229-
faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img
222+
faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.raspberry-pi-nix.firmware-partition-label} firmware_part.img
230223
231224
# Populate the files intended for /boot/firmware
232225
mkdir firmware
@@ -244,7 +237,8 @@ in {
244237
zstd -T$NIX_BUILD_CORES --rm $img
245238
fi
246239
'';
247-
}) { };
240+
})
241+
{ };
248242

249243
boot.postBootCommands = lib.mkIf config.sdImage.expandOnBoot ''
250244
# On the first boot do some maintenance tasks

0 commit comments

Comments
 (0)