Skip to content
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

Add configration option for partition UUIDs #951

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Rua
Copy link

@Rua Rua commented Jan 24, 2025

Closes #948. This is my first ever Nix-related PR, so I'd appreciate feedback if you have any!

I wasn't sure if mdadm does expose partuuid, I assumed that it did but that may be wrong. I did run the tests, but I wasn't sure if it was wise to include UUIDs in example files. It's probably not a good idea for users to copy the UUID, they should generate their own.

Copy link

@nbraud nbraud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good work. I agree, such an option would be quite valuable 👍

The disko devs might ask for tests as well ^^

@@ -74,6 +79,16 @@ in
description = "Name of the partition";
default = name;
};
uuid = lib.mkOption {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call the option guid so it's harder to mistake for the filesystem's id?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I called it uuid because, within the Linux context, it's always referred as that. For example, the name of /dev/disk/by-partuuid, blkid calls it PARTUUID etc. I could have named it partuuid, but I figured that if there is ever a separate filesystem UUID option, that would be distinguished as partition.content.uuid vs partition.uuid.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works.

default = null;
example = "809b3a2b-828a-4730-95e1-75b6343e415a";
description = ''
The UUID (also known as GUID) of the partition. Note that this is distinct from the UUID of the filesystem.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document which types of partition table support the option. Maybe also add a corresponding assertion to the module, to give a clear error rather than unexpected behaviour.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does disko support anything other than GPT? At least, I included it in the gpt.nix module assuming that it would only be available for GPT.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently we still support DOS with the legacy table, but that is deprecated and it's fine to do it here for gpt only

lib/types/gpt.nix Outdated Show resolved Hide resolved
lib/types/gpt.nix Outdated Show resolved Hide resolved
Comment on lines +215 to +224
args = ''
--partition-guid="${toString partition._index}:${if partition.uuid == null then "R" else partition.uuid}" \
--change-name="${toString partition._index}:${partition.label}" \
--typecode=${toString partition._index}:${partition.type} \
"${config.device}" \
'';
createArgs = ''
--align-end ${lib.optionalString (partition.alignment != 0) ''--set-alignment=${builtins.toString partition.alignment}''} \
--new=${toString partition._index}:${partition.start}:${partition.end} \
'';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this was split, but isn' the device more of a createArg?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to avoid repeating itself, nothing more. It seemed nicer this way. I can revert it to the original style if you want.

Copy link

@nbraud nbraud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to set UUID of partitions
3 participants