Skip to content

Commit

Permalink
filesystems: Add autoResize assertion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
talyz committed Mar 16, 2019
1 parent 0610d30 commit 0eb6d07
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nixos/modules/tasks/filesystems.nix
Expand Up @@ -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
Expand Down

0 comments on commit 0eb6d07

Please sign in to comment.