Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #95406 from Mic92/mountpoint-type

nixos/filesystems: don't allow mountpoints with trailing slash

authored by Kevin Cox and committed by GitHub 969e43e3 13efba98

+5 -4
+5 -4
nixos/modules/tasks/filesystems.nix
··· 7 7 8 8 addCheckDesc = desc: elemType: check: types.addCheck elemType check 9 9 // { description = "${elemType.description} (with check: ${desc})"; }; 10 - nonEmptyStr = addCheckDesc "non-empty" types.str 11 - (x: x != "" && ! (all (c: c == " " || c == "\t") (stringToCharacters x))); 10 + 11 + isNonEmpty = s: (builtins.match "[ \t\n]*" s) == null; 12 + nonEmptyStr = addCheckDesc "non-empty" types.str isNonEmpty; 12 13 13 14 fileSystems' = toposort fsBefore (attrValues config.fileSystems); 14 15 ··· 28 29 coreFileSystemOpts = { name, config, ... }: { 29 30 30 31 options = { 31 - 32 32 mountPoint = mkOption { 33 33 example = "/mnt/usb"; 34 - type = nonEmptyStr; 34 + type = addCheckDesc "non-empty without trailing slash" types.str 35 + (s: isNonEmpty s && (builtins.match ".+/" s) == null); 35 36 description = "Location of the mounted the file system."; 36 37 }; 37 38