Merge pull request #291825 from WilliButz/repart/max-label-length

nixos/systemd-repart: add assertion for partition label length

authored by Will Fancher and committed by GitHub b9fe04d6 a587a6a3

+15 -1
+15 -1
nixos/modules/system/boot/systemd/repart.nix
··· 10 10 "repart.d" 11 11 format 12 12 (lib.mapAttrs (_n: v: { Partition = v; }) cfg.partitions); 13 + 14 + partitionAssertions = lib.mapAttrsToList (fileName: definition: 15 + let 16 + maxLabelLength = 36; # GPT_LABEL_MAX defined in systemd's gpt.h 17 + labelLength = builtins.stringLength definition.Label; 18 + in 19 + { 20 + assertion = definition ? Label -> maxLabelLength >= labelLength; 21 + message = '' 22 + The partition label '${definition.Label}' defined for '${fileName}' is ${toString labelLength} 23 + characters long, but the maximum label length supported by systemd is ${toString maxLabelLength}. 24 + ''; 25 + } 26 + ) cfg.partitions; 13 27 in 14 28 { 15 29 options = { ··· 81 95 'boot.initrd.systemd.repart.enable' requires 'boot.initrd.systemd.enable' to be enabled. 82 96 ''; 83 97 } 84 - ]; 98 + ] ++ partitionAssertions; 85 99 86 100 # systemd-repart uses loopback devices for partition creation 87 101 boot.initrd.availableKernelModules = lib.optional initrdCfg.enable "loop";