summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2019-03-16 12:51:18 +0100
committertalyz <kim.lindberger@gmail.com>2019-03-16 13:01:35 +0100
commit0eb6d0735f599fa84e99b727c93681bcae96c845 (patch)
tree54a66d932da1b3cbb9cb14f810ebd3a23799bc04
parent0610d30e5b9920787c0b53a271b0cd1fde66aeb2 (diff)
filesystems: Add autoResize assertion
Assert that autoResize is only used when fsType is explicitly set to a supported filesystem: if it's set to "auto", the default, the required resizing tools won't be copied into the initrd even if the actual filesystem is supported.
-rw-r--r--nixos/modules/tasks/filesystems.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index 07f8214cea2c..43764bb82f1f 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -209,10 +209,17 @@ in
assertions = let
ls = sep: concatMapStringsSep sep (x: x.mountPoint);
+ notAutoResizable = fs: fs.autoResize && !(hasPrefix "ext" fs.fsType || fs.fsType == "f2fs");
in [
{ assertion = ! (fileSystems' ? "cycle");
message = "The ‘fileSystems’ option can't be topologically sorted: mountpoint dependency path ${ls " -> " fileSystems'.cycle} loops to ${ls ", " fileSystems'.loops}";
}
+ { assertion = ! (any notAutoResizable fileSystems);
+ message = let
+ fs = head (filter notAutoResizable fileSystems);
+ in
+ "Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${if fs.fsType == "auto" then " fsType has to be explicitly set and" else ""} only the ext filesystems and f2fs support it.";
+ }
];
# Export for use in other modules