Skip to content

Commit

Permalink
Merge pull request #284174 from jmbaur/repart-sector-size
Browse files Browse the repository at this point in the history
Fix appliance-repart-image NixOS VM test
  • Loading branch information
RaitoBezarius authored Jan 30, 2024
2 parents 6446f96 + 0bf5f3b commit 386c037
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nixos/modules/image/repart-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
, split
, seed
, definitionsDirectory
, sectorSize
}:

let
Expand Down Expand Up @@ -94,6 +95,7 @@ runCommand imageFileBasename
--definitions="$amendedRepartDefinitions" \
--split="${lib.boolToString split}" \
--json=pretty \
${lib.optionalString (sectorSize != null) "--sector-size=${toString sectorSize}"} \
${imageFileBasename}.raw \
| tee repart-output.json
Expand Down
12 changes: 11 additions & 1 deletion nixos/modules/image/repart.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
# We use buildPackages so that repart images are built with the build
# platform's systemd, allowing for cross-compiled systems to work.
Expand Down Expand Up @@ -232,7 +242,7 @@ in
in
pkgs.callPackage ./repart-image.nix {
systemd = cfg.package;
inherit (cfg) imageFileBasename compression split seed;
inherit (cfg) imageFileBasename compression split seed sectorSize;
inherit fileSystems definitionsDirectory partitions;
};

Expand Down
2 changes: 2 additions & 0 deletions nixos/tests/appliance-repart-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ in

image.repart = {
name = "appliance-gpt-image";
# OVMF does not work with the default repart sector size of 4096
sectorSize = 512;
partitions = {
"esp" = {
contents =
Expand Down

0 comments on commit 386c037

Please sign in to comment.