mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
nixos/filesystems: don't allow mountpoints with trailing slash
They are semantically the same as the non-slash version and therefore are potential source of duplicates. Also fixes https://github.com/NixOS/nixpkgs/issues/78951 Alternative to https://github.com/NixOS/nixpkgs/pull/95308
This commit is contained in:
parent
01ea0b5722
commit
76360c005f
@ -7,8 +7,9 @@ let
|
||||
|
||||
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)));
|
||||
|
||||
isNonEmpty = s: (builtins.match "[ \t\n]*" s) == null;
|
||||
nonEmptyStr = addCheckDesc "non-empty" types.str isNonEmpty;
|
||||
|
||||
fileSystems' = toposort fsBefore (attrValues config.fileSystems);
|
||||
|
||||
@ -28,10 +29,10 @@ let
|
||||
coreFileSystemOpts = { name, config, ... }: {
|
||||
|
||||
options = {
|
||||
|
||||
mountPoint = mkOption {
|
||||
example = "/mnt/usb";
|
||||
type = nonEmptyStr;
|
||||
type = addCheckDesc "non-empty without trailing slash" types.str
|
||||
(s: isNonEmpty s && (builtins.match ".+/" s) == null);
|
||||
description = "Location of the mounted the file system.";
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user