nixos/repart: add option for configuring sector size

This option is helpful for situations when the target host disk's sector
size differs from that of the build host.
This commit is contained in:
Jared Baur 2024-01-26 22:26:46 -08:00
parent 99b67695f5
commit 4e139026b5
No known key found for this signature in database
2 changed files with 13 additions and 1 deletions

View file

@ -32,6 +32,7 @@
, split , split
, seed , seed
, definitionsDirectory , definitionsDirectory
, sectorSize
}: }:
let let
@ -94,6 +95,7 @@ runCommand imageFileBasename
--definitions="$amendedRepartDefinitions" \ --definitions="$amendedRepartDefinitions" \
--split="${lib.boolToString split}" \ --split="${lib.boolToString split}" \
--json=pretty \ --json=pretty \
${lib.optionalString (sectorSize != null) "--sector-size=${toString sectorSize}"} \
${imageFileBasename}.raw \ ${imageFileBasename}.raw \
| tee repart-output.json | tee repart-output.json

View file

@ -135,6 +135,16 @@ in
''; '';
}; };
sectorSize = lib.mkOption {
type = with lib.types; nullOr int;
default = 512;
example = lib.literalExpression "4096";
description = lib.mdDoc ''
The sector size of the disk image produced by systemd-repart. This
value must be a power of 2 between 512 and 4096.
'';
};
package = lib.mkPackageOption pkgs "systemd-repart" { package = lib.mkPackageOption pkgs "systemd-repart" {
# We use buildPackages so that repart images are built with the build # We use buildPackages so that repart images are built with the build
# platform's systemd, allowing for cross-compiled systems to work. # platform's systemd, allowing for cross-compiled systems to work.
@ -232,7 +242,7 @@ in
in in
pkgs.callPackage ./repart-image.nix { pkgs.callPackage ./repart-image.nix {
systemd = cfg.package; systemd = cfg.package;
inherit (cfg) imageFileBasename compression split seed; inherit (cfg) imageFileBasename compression split seed sectorSize;
inherit fileSystems definitionsDirectory partitions; inherit fileSystems definitionsDirectory partitions;
}; };