···525525 )}
526526 '';
527527528528+ # The maximum number of characters allowed in a GPT partition label. This
529529+ # limit is specified by UEFI and enforced by systemd-repart.
530530+ # Corresponds to GPT_LABEL_MAX from systemd's gpt.h.
531531+ GPTMaxLabelLength = 36;
532532+528533}
+38
nixos/modules/image/repart.nix
···66let
77 cfg = config.image.repart;
8899+ inherit (utils.systemdUtils.lib) GPTMaxLabelLength;
1010+911 partitionOptions = {
1012 options = {
1113 storePaths = lib.mkOption {
···223225 };
224226225227 config = {
228228+229229+ assertions = lib.mapAttrsToList (fileName: partitionConfig:
230230+ let
231231+ inherit (partitionConfig) repartConfig;
232232+ labelLength = builtins.stringLength repartConfig.Label;
233233+ in
234234+ {
235235+ assertion = repartConfig ? Label -> GPTMaxLabelLength >= labelLength;
236236+ message = ''
237237+ The partition label '${repartConfig.Label}'
238238+ defined for '${fileName}' is ${toString labelLength} characters long,
239239+ but the maximum label length supported by UEFI is ${toString
240240+ GPTMaxLabelLength}.
241241+ '';
242242+ }
243243+ ) cfg.partitions;
244244+245245+ warnings = lib.filter (v: v != null) (lib.mapAttrsToList (fileName: partitionConfig:
246246+ let
247247+ inherit (partitionConfig) repartConfig;
248248+ suggestedMaxLabelLength = GPTMaxLabelLength - 2;
249249+ labelLength = builtins.stringLength repartConfig.Label;
250250+ in
251251+ if (repartConfig ? Label && labelLength >= suggestedMaxLabelLength) then ''
252252+ The partition label '${repartConfig.Label}'
253253+ defined for '${fileName}' is ${toString labelLength} characters long.
254254+ The suggested maximum label length is ${toString
255255+ suggestedMaxLabelLength}.
256256+257257+ If you use sytemd-sysupdate style A/B updates, this might
258258+ not leave enough space to increment the version number included in
259259+ the label in a future release. For example, if your label is
260260+ ${toString GPTMaxLabelLength} characters long (the maximum enforced by UEFI) and
261261+ you're at version 9, you cannot increment this to 10.
262262+ '' else null
263263+ ) cfg.partitions);
226264227265 image.repart =
228266 let
+3-3
nixos/modules/system/boot/systemd/repart.nix
···13131414 partitionAssertions = lib.mapAttrsToList (fileName: definition:
1515 let
1616- maxLabelLength = 36; # GPT_LABEL_MAX defined in systemd's gpt.h
1616+ inherit (utils.systemdUtils.lib) GPTMaxLabelLength;
1717 labelLength = builtins.stringLength definition.Label;
1818 in
1919 {
2020- assertion = definition ? Label -> maxLabelLength >= labelLength;
2020+ assertion = definition ? Label -> GPTMaxLabelLength >= labelLength;
2121 message = ''
2222 The partition label '${definition.Label}' defined for '${fileName}' is ${toString labelLength}
2323- characters long, but the maximum label length supported by systemd is ${toString maxLabelLength}.
2323+ characters long, but the maximum label length supported by systemd is ${toString GPTMaxLabelLength}.
2424 '';
2525 }
2626 ) cfg.partitions;