Skip to content

gpt: add partition attributes #1069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/types/gpt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ in
or a fully specified GUID (see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs).
'';
};
attributes = lib.mkOption {
type = lib.types.listOf lib.types.int;
default = [ ];
description = ''
GPT partition entry attributes, according to UEFI specification
2.10 (see https://uefi.org/specs/UEFI/2.10_A/05_GUID_Partition_Table_Format.html#defined-gpt-partition-entry-attributes)
and `sgdisk`s man page:

- 0: Required Partition (`sgdisk`: system partition)
- 1: No Block IO Protocol (`sgdisk`: hide from EFI)
- 2: Legacy BIOS Bootable
- 3-47: Undefined and must be zero, reserved for future use
- 48-63: Reserved for GUID specific use. The use of these bits
will vary depending on the partition type

`sgdisk` describes some of the GUID-specific bits this way:
- 60: read only
- 62: hidden
- 63: do not automount
'';
};
device = lib.mkOption {
type = lib.types.str;
default =
Expand Down Expand Up @@ -268,6 +289,14 @@ in
}" \
--change-name="${toString partition._index}:${partition.label}" \
--typecode=${toString partition._index}:${partition.type} \
--attributes=${toString partition._index}:=:0 \
${
lib.concatStringsSep " \\\n" (
builtins.map (
bitNumber: "--attributes=${toString partition._index}:set:${toString bitNumber}"
) partition.attributes
)
} \
"${config.device}" \
'';
createArgs = ''
Expand Down