mirror of
https://github.com/nix-community/disko.git
synced 2024-11-04 05:44:29 +03:00
types gpt: hash label if it's > 36 characters
This commit is contained in:
parent
3cb3775f9b
commit
56f6d3d4af
@ -55,7 +55,15 @@ in
|
|||||||
};
|
};
|
||||||
label = lib.mkOption {
|
label = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "${config._parent.type}-${config._parent.name}-${partition.config.name}";
|
default = let
|
||||||
|
# 72 bytes is the maximum length of a GPT partition name
|
||||||
|
# the labels seem to be in UTF-16, so 2 bytes per character
|
||||||
|
limit = 36;
|
||||||
|
label = "${config._parent.type}-${config._parent.name}-${partition.config.name}";
|
||||||
|
in if (lib.stringLength label) > limit then
|
||||||
|
builtins.substring 0 limit (builtins.hashString "sha256" label)
|
||||||
|
else
|
||||||
|
label;
|
||||||
};
|
};
|
||||||
size = lib.mkOption {
|
size = lib.mkOption {
|
||||||
type = lib.types.either (lib.types.enum [ "100%" ]) (lib.types.strMatching "[0-9]+[KMGTP]?");
|
type = lib.types.either (lib.types.enum [ "100%" ]) (lib.types.strMatching "[0-9]+[KMGTP]?");
|
||||||
|
Loading…
Reference in New Issue
Block a user