Skip to content

Commit bacbe94

Browse files
nvmdstepbrobd
authored andcommitted
gpt: add partition attributes
1 parent 7f1857b commit bacbe94

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lib/types/gpt.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ in
5757
or a fully specified GUID (see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs).
5858
'';
5959
};
60+
attributes = lib.mkOption {
61+
type = lib.types.listOf lib.types.int;
62+
default = [ ];
63+
description = ''
64+
GPT partition entry attributes, according to UEFI specification
65+
2.10 (see https://uefi.org/specs/UEFI/2.10_A/05_GUID_Partition_Table_Format.html#defined-gpt-partition-entry-attributes)
66+
and `sgdisk`s man page:
67+
68+
- 0: Required Partition (`sgdisk`: system partition)
69+
- 1: No Block IO Protocol (`sgdisk`: hide from EFI)
70+
- 2: Legacy BIOS Bootable
71+
- 3-47: Undefined and must be zero, reserved for future use
72+
- 48-63: Reserved for GUID specific use. The use of these bits
73+
will vary depending on the partition type
74+
75+
`sgdisk` describes some of the GUID-specific bits this way:
76+
- 60: read only
77+
- 62: hidden
78+
- 63: do not automount
79+
'';
80+
};
6081
device = lib.mkOption {
6182
type = lib.types.str;
6283
default =
@@ -268,6 +289,14 @@ in
268289
}" \
269290
--change-name="${toString partition._index}:${partition.label}" \
270291
--typecode=${toString partition._index}:${partition.type} \
292+
--attributes=${toString partition._index}:=:0 \
293+
${
294+
lib.concatStringsSep " \\\n" (
295+
builtins.map (
296+
bitNumber: "--attributes=${toString partition._index}:set:${toString bitNumber}"
297+
) partition.attributes
298+
)
299+
} \
271300
"${config.device}" \
272301
'';
273302
createArgs = ''

0 commit comments

Comments
 (0)