Skip to content

Commit

Permalink
make partitions.alignment configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4A6F committed Apr 9, 2024
1 parent 79eab0e commit 07b7d66
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/types/gpt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ in
can be 100% for the whole remaining disk, will be done last in that case.
'';
};
alignment = lib.mkOption {
type = lib.types.int;
default = if (builtins.substring (builtins.stringLength partition.config.start - 1) 1 partition.config.start == "s" || (builtins.substring (builtins.stringLength partition.config.end - 1) 1 partition.config.end == "s" )) then 1 else 0;
description = "Alignment of the partition, if sectors are used as start or end it can be aligned to 1";
};
start = lib.mkOption {
type = lib.types.str;
default = "0";
Expand Down Expand Up @@ -159,7 +164,7 @@ in
${lib.concatStrings (map (partition: ''
# try to create the partition, if it fails, try to change the type and name
if ! sgdisk \
--align-end \
--align-end ${lib.optionalString (partition.alignment != 0) ''--set-alignment=${builtins.toString partition.alignment}''} \
--new=${toString partition._index}:${partition.start}:${partition.end} \
--change-name=${toString partition._index}:${partition.label} \
--typecode=${toString partition._index}:${partition.type} \
Expand Down

0 comments on commit 07b7d66

Please sign in to comment.