Merge pull request #95406 from Mic92/mountpoint-type

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

Changed files
+5 -4
nixos
modules
+5 -4
nixos/modules/tasks/filesystems.nix
···
addCheckDesc = desc: elemType: check: types.addCheck elemType check
// { description = "${elemType.description} (with check: ${desc})"; };
-
nonEmptyStr = addCheckDesc "non-empty" types.str
-
(x: x != "" && ! (all (c: c == " " || c == "\t") (stringToCharacters x)));
fileSystems' = toposort fsBefore (attrValues config.fileSystems);
···
coreFileSystemOpts = { name, config, ... }: {
options = {
-
mountPoint = mkOption {
example = "/mnt/usb";
-
type = nonEmptyStr;
description = "Location of the mounted the file system.";
};
···
addCheckDesc = desc: elemType: check: types.addCheck elemType check
// { description = "${elemType.description} (with check: ${desc})"; };
+
+
isNonEmpty = s: (builtins.match "[ \t\n]*" s) == null;
+
nonEmptyStr = addCheckDesc "non-empty" types.str isNonEmpty;
fileSystems' = toposort fsBefore (attrValues config.fileSystems);
···
coreFileSystemOpts = { name, config, ... }: {
options = {
mountPoint = mkOption {
example = "/mnt/usb";
+
type = addCheckDesc "non-empty without trailing slash" types.str
+
(s: isNonEmpty s && (builtins.match ".+/" s) == null);
description = "Location of the mounted the file system.";
};