Commit c43bc416 authored by phaer's avatar phaer
Browse files

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".
parent 0ec0d58f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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
            ;