summaryrefslogtreecommitdiffstats
path: root/nixos/modules/tasks/filesystems.nix
diff options
context:
space:
mode:
authorRickard Nilsson <rickynils@gmail.com>2014-05-09 14:32:12 +0200
committerRickard Nilsson <rickynils@gmail.com>2014-05-09 16:49:03 +0200
commitb87b6870f81c66b34c6eab1857f642b66b68c114 (patch)
treea7f2c3f615b8b351c9a31a3654944bb1deb857a9 /nixos/modules/tasks/filesystems.nix
parentea36f3b86892263d172fa3d0d0d4ae00d82a0edc (diff)
When auto-formatting ext devices, use the -F flag to make it work with unpartioned disks
Diffstat (limited to 'nixos/modules/tasks/filesystems.nix')
-rw-r--r--nixos/modules/tasks/filesystems.nix4
1 files changed, 3 insertions, 1 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index 954d0b0781f7..d350bc1b5d0e 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -187,6 +187,8 @@ 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" ];
@@ -201,7 +203,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} "${fs.device}"
+ mkfs.${fs.fsType} ${concatStringsSep " " mkfsOpts} "${fs.device}"
fi
'';
unitConfig.RequiresMountsFor = [ "${dirOf fs.device}" ];