diff options
author | Profpatsch <mail@profpatsch.de> | 2017-02-15 13:22:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-15 13:22:48 +0100 |
commit | 91d0260feba50b25b13d1e0dd2705039f75e09a2 (patch) | |
tree | 364020ff93657682cff47755a3108979e3c73137 /nixos/modules | |
parent | cb2499acd0c6a9de9bbf62d751ba35dfdd29ee63 (diff) | |
download | nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar.gz nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar.bz2 nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar.lz nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar.xz nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.tar.zst nixlib-91d0260feba50b25b13d1e0dd2705039f75e09a2.zip |
modules/filesystems: disallow non-empty fstab fields (#22803)
It was possible to pass empty strings / strings with only separator characters; this lead to broken fstab formatting.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/tasks/filesystems.nix | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index 8bd35385739e..8a4299113f2b 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -5,6 +5,11 @@ with utils; 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))); + fileSystems' = toposort fsBefore (attrValues config.fileSystems); fileSystems = if fileSystems' ? "result" @@ -26,21 +31,21 @@ let mountPoint = mkOption { example = "/mnt/usb"; - type = types.str; + type = nonEmptyStr; description = "Location of the mounted the file system."; }; device = mkOption { default = null; example = "/dev/sda"; - type = types.nullOr types.str; + type = types.nullOr nonEmptyStr; description = "Location of the device."; }; fsType = mkOption { default = "auto"; example = "ext3"; - type = types.str; + type = nonEmptyStr; description = "Type of the file system."; }; @@ -48,7 +53,7 @@ let default = [ "defaults" ]; example = [ "data=journal" ]; description = "Options used to mount the file system."; - type = types.listOf types.str; + type = types.listOf nonEmptyStr; }; }; @@ -67,7 +72,7 @@ let label = mkOption { default = null; example = "root-partition"; - type = types.nullOr types.str; + type = types.nullOr nonEmptyStr; description = "Label of the device (if any)."; }; |