diff --git a/nixos/modules/image/repart-image.nix b/nixos/modules/image/repart-image.nix index e8047757117d..9b4447b18816 100644 --- a/nixos/modules/image/repart-image.nix +++ b/nixos/modules/image/repart-image.nix @@ -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" diff --git a/nixos/modules/image/repart.nix b/nixos/modules/image/repart.nix index bc1e0eb2f41d..047142dc468a 100644 --- a/nixos/modules/image/repart.nix +++ b/nixos/modules/image/repart.nix @@ -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 ;