filesystems: use list of strings for fs options

Allow usage of list of strings instead of a comma-separated string
for filesystem options. Deprecate the comma-separated string style
with a warning message; convert this to a hard error after 16.09.
15.09 was just released, so this provides a deprecation period during
the 16.03 release.

closes #10518

Signed-off-by: Robin Gloster <mail@glob.in>
This commit is contained in:
Aneesh Agrawal
2016-02-06 19:48:30 +00:00
committed by Robin Gloster
parent f7aa921773
commit 3c5fca9618
10 changed files with 46 additions and 25 deletions
+11 -7
View File
@@ -41,11 +41,15 @@ let
};
options = mkOption {
default = "defaults";
example = "data=journal";
type = types.commas; # FIXME: should be a list
default = [ "defaults" ];
example = [ "data=journal" ];
description = "Options used to mount the file system.";
};
} // (if versionAtLeast lib.nixpkgsVersion "16.09" then {
type = types.listOf types.str;
} else {
type = types.either types.commas (types.listOf types.str);
apply = x: if isList x then x else lib.strings.splitString "," (builtins.trace "warning: passing a comma-separated string for filesystem options is deprecated; use a list of strings instead. This will become a hard error in 16.09." x);
});
autoFormat = mkOption {
default = false;
@@ -112,7 +116,7 @@ in
"/data" = {
device = "/dev/hda2";
fsType = "ext3";
options = "data=journal";
options = [ "data=journal" ];
};
"/bigdisk".label = "bigdisk";
};
@@ -127,7 +131,7 @@ in
<command>mount</command>; defaults to
<literal>"auto"</literal>), and <literal>options</literal>
(the mount options passed to <command>mount</command> using the
<option>-o</option> flag; defaults to <literal>"defaults"</literal>).
<option>-o</option> flag; defaults to <literal>[ "defaults" ]</literal>).
Instead of specifying <literal>device</literal>, you can also
specify a volume label (<literal>label</literal>) for file
@@ -177,7 +181,7 @@ in
else throw "No device specified for mount point ${fs.mountPoint}.")
+ " " + fs.mountPoint
+ " " + fs.fsType
+ " " + fs.options
+ " " + builtins.concatStringsSep "," fs.options
+ " 0"
+ " " + (if skipCheck fs then "0" else
if fs.mountPoint == "/" then "1" else "2")