diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2020-08-14 07:25:50 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2021-01-25 11:10:03 +0100 |
commit | 76360c005fbc560dc1f4564a920546a9dfc27447 (patch) | |
tree | 151e9c70143c155254b0e8ae7c814be17e8df0a0 | |
parent | 01ea0b5722f2d211c9268df9448c9106604052b0 (diff) | |
download | nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar.gz nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar.bz2 nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar.lz nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar.xz nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.tar.zst nixpkgs-76360c005fbc560dc1f4564a920546a9dfc27447.zip |
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
-rw-r--r-- | nixos/modules/tasks/filesystems.nix | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index a055072f9c9..a9b5b134d88 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -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."; }; |