diff options
author | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-10-04 03:14:53 +0200 |
---|---|---|
committer | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-10-04 03:15:29 +0200 |
commit | 8a63ae526f259795c2dcc5eb28f0648293baedcf (patch) | |
tree | bd68ed4093d4ee65cd2e21a09fc5db82958d1ced /nixos/modules/tasks/filesystems.nix | |
parent | e916273209560b302ab231606babf5ce1c481f08 (diff) | |
download | nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar.gz nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar.bz2 nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar.lz nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar.xz nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.tar.zst nixlib-8a63ae526f259795c2dcc5eb28f0648293baedcf.zip |
add support for auto format, format options
Diffstat (limited to 'nixos/modules/tasks/filesystems.nix')
-rw-r--r-- | nixos/modules/tasks/filesystems.nix | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index 9dd250f140ce..5f21e668f7ed 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -58,6 +58,15 @@ let ''; }; + formatOptions = mkOption { + default = ""; + type = types.str; + description = '' + If <option>autoFormat</option> option is set specifies + extra options passed to mkfs. + ''; + }; + autoResize = mkOption { default = false; type = types.bool; @@ -81,6 +90,9 @@ let mountPoint = mkDefault name; device = mkIf (config.fsType == "tmpfs") (mkDefault config.fsType); options = mkIf config.autoResize "x-nixos.autoresize"; + + # -F needed to allow bare block device without partitions + formatOptions = mkIf ((builtins.substring 0 3 config.fsType) == "ext") (mkDefault "-F"); }; }; @@ -192,8 +204,6 @@ in let mountPoint' = escapeSystemdPath fs.mountPoint; device' = escapeSystemdPath fs.device; - # -F needed to allow bare block device without partitions - mkfsOpts = optional ((builtins.substring 0 3 fs.fsType) == "ext") "-F"; in nameValuePair "mkfs-${device'}" { description = "Initialisation of Filesystem ${fs.device}"; wantedBy = [ "${mountPoint'}.mount" ]; @@ -208,7 +218,7 @@ in type=$(blkid -p -s TYPE -o value "${fs.device}" || true) if [ -z "$type" ]; then echo "creating ${fs.fsType} filesystem on ${fs.device}..." - mkfs.${fs.fsType} ${concatStringsSep " " mkfsOpts} "${fs.device}" + mkfs.${fs.fsType} ${fs.formatOptions} "${fs.device}" fi ''; unitConfig.RequiresMountsFor = [ "${dirOf fs.device}" ]; |