Skip to content

Commit

Permalink
lib/types/gpt: accept GUID type to set the partition type
Browse files Browse the repository at this point in the history
See [the wikipedia article on GUID types][wiki_guid]
and the sgdisk man page on `--typecode`.

[wiki_guid]: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
  • Loading branch information
r-vdp authored and mergify[bot] committed Jan 3, 2024
1 parent 59f915b commit aef9a50
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/types/gpt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ in
type = lib.types.attrsOf (lib.types.submodule ({ name, ... }@partition: {
options = {
type = lib.mkOption {
type = lib.types.strMatching "[A-Fa-f0-9]{4}";
type =
let
hexPattern = len: "[A-Fa-f0-9]{${toString len}}";
in
lib.types.either
(lib.types.strMatching (hexPattern 4))
(lib.types.strMatching (lib.concatMapStringsSep "-" hexPattern [ 8 4 4 4 12 ]));
default = "8300";
description = "Filesystem type to use, run sgdisk -L to see what is available";
description = ''
Filesystem type to use.
This can either be an sgdisk-specific short code (run sgdisk -L to see what is available),
or a fully specified GUID (see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs).
'';
};
device = lib.mkOption {
type = lib.types.str;
Expand Down Expand Up @@ -76,7 +86,7 @@ in
};
};
}));
default = {};
default = { };
description = "Attrs of partitions to add to the partition table";
};
_parent = lib.mkOption {
Expand Down

0 comments on commit aef9a50

Please sign in to comment.