image/repart: add image.repart.imageSize for --size

This allows users to specify their desired total size of the generated
disk image. This is useful to e.g. match the size of a target medium to
have a appropriately sized filesystems even before first boot.

It's a noop for the default value of "auto".
This commit is contained in:
phaer
2025-11-26 00:32:34 +01:00
parent 0ec0d58f82
commit c43bc416f0
2 changed files with 11 additions and 1 deletions
+2 -1
View File
@@ -37,6 +37,7 @@
split,
seed,
definitionsDirectory,
imageSize ? "auto",
sectorSize,
mkfsEnv ? { },
createEmpty ? true,
@@ -170,7 +171,7 @@ stdenvNoCC.mkDerivation (
systemdRepartFlags = [
"--architecture=${systemdArch}"
"--dry-run=no"
"--size=auto"
"--size=${imageSize}"
"--definitions=${finalAttrs.finalRepartDefinitions}"
"--split=${lib.boolToString split}"
"--json=pretty"
+9
View File
@@ -201,6 +201,14 @@ in
'';
};
imageSize = lib.mkOption {
type = lib.types.strMatching "^([0-9]+[KMGTP]?|auto)$";
default = "auto";
example = "512G";
description = "Size of the produced image in bytes with optional K, M, G, T suffix,
or 'auto' to determine the minimal size automatically";
};
package = lib.mkPackageOption pkgs "systemd-repart" {
# We use buildPackages so that repart images are built with the build
# platform's systemd, allowing for cross-compiled systems to work.
@@ -415,6 +423,7 @@ in
compression
split
seed
imageSize
sectorSize
finalPartitions
;