diff options
author | Jared Baur <jaredbaur@fastmail.com> | 2024-01-26 22:26:46 -0800 |
---|---|---|
committer | Jared Baur <jaredbaur@fastmail.com> | 2024-01-27 17:19:32 -0800 |
commit | 4e139026b506e2339c6ce224e2f7ad1e4bb4fa4b (patch) | |
tree | b86742b89225e52de3f56b7d762edd1bf96d3e9e /nixos/modules/image | |
parent | 99b67695f563a2b268431d8ab3e5d673642671f8 (diff) |
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.
Diffstat (limited to 'nixos/modules/image')
-rw-r--r-- | nixos/modules/image/repart-image.nix | 2 | ||||
-rw-r--r-- | nixos/modules/image/repart.nix | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/nixos/modules/image/repart-image.nix b/nixos/modules/image/repart-image.nix index a12b4fb14fb16..7ac47ee32ff43 100644 --- a/nixos/modules/image/repart-image.nix +++ b/nixos/modules/image/repart-image.nix @@ -32,6 +32,7 @@ , split , seed , definitionsDirectory +, sectorSize }: let @@ -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 diff --git a/nixos/modules/image/repart.nix b/nixos/modules/image/repart.nix index ed584d9bf997b..6a933f0d83ccc 100644 --- a/nixos/modules/image/repart.nix +++ b/nixos/modules/image/repart.nix @@ -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. @@ -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; }; |