mirror of
https://github.com/nix-community/raspberry-pi-nix.git
synced 2025-11-08 11:36:04 +01:00
add firmware-partition-label option
This commit is contained in:
parent
61d43e92fd
commit
beb01f006a
2 changed files with 12 additions and 13 deletions
|
|
@ -26,6 +26,11 @@ in
|
||||||
without the _defconfig part.
|
without the _defconfig part.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
firmware-partition-label = mkOption {
|
||||||
|
default = "FIRMWARE";
|
||||||
|
type = types.str;
|
||||||
|
description = "label of rpi firmware partition";
|
||||||
|
};
|
||||||
pin-inputs = {
|
pin-inputs = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
|
|
@ -94,7 +99,7 @@ in
|
||||||
{
|
{
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
MountImages =
|
MountImages =
|
||||||
"/dev/disk/by-label/FIRMWARE:${firmware-path}";
|
"/dev/disk/by-label/${cfg.firmware-partition-label}:${firmware-path}";
|
||||||
StateDirectory = "raspberrypi-firmware";
|
StateDirectory = "raspberrypi-firmware";
|
||||||
ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" ''
|
ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" ''
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ let
|
||||||
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
|
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
|
||||||
uuid = config.sdImage.rootPartitionUUID;
|
uuid = config.sdImage.rootPartitionUUID;
|
||||||
});
|
});
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
options.sdImage = {
|
options.sdImage = {
|
||||||
|
|
@ -82,14 +83,6 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
firmwarePartitionName = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "FIRMWARE";
|
|
||||||
description = ''
|
|
||||||
Name of the filesystem which holds the boot firmware.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
rootPartitionUUID = mkOption {
|
rootPartitionUUID = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
default = null;
|
||||||
|
|
@ -160,7 +153,7 @@ in {
|
||||||
config = {
|
config = {
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
"/boot/firmware" = {
|
"/boot/firmware" = {
|
||||||
device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}";
|
device = "/dev/disk/by-label/${config.raspberry-pi-nix.firmware-partition-label}";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
"/" = {
|
"/" = {
|
||||||
|
|
@ -226,7 +219,7 @@ in {
|
||||||
# Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
|
# Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
|
||||||
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
|
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
|
||||||
truncate -s $((SECTORS * 512)) firmware_part.img
|
truncate -s $((SECTORS * 512)) firmware_part.img
|
||||||
faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img
|
faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.raspberry-pi-nix.firmware-partition-label} firmware_part.img
|
||||||
|
|
||||||
# Populate the files intended for /boot/firmware
|
# Populate the files intended for /boot/firmware
|
||||||
mkdir firmware
|
mkdir firmware
|
||||||
|
|
@ -244,7 +237,8 @@ in {
|
||||||
zstd -T$NIX_BUILD_CORES --rm $img
|
zstd -T$NIX_BUILD_CORES --rm $img
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
}) { };
|
})
|
||||||
|
{ };
|
||||||
|
|
||||||
boot.postBootCommands = lib.mkIf config.sdImage.expandOnBoot ''
|
boot.postBootCommands = lib.mkIf config.sdImage.expandOnBoot ''
|
||||||
# On the first boot do some maintenance tasks
|
# On the first boot do some maintenance tasks
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue