Author: eelco
Date: Wed May 16 00:03:44 2012
New Revision: 34133
URL: https://nixos.org/websvn/nix/?rev=34133&sc=1
Log:
* Add a filesystem option ‘autoFormat’ to automatically do a format if
the device has no filesystem yet. Useful in Charon deployments.
The check for an uninitialised filesystem is kind of shaky now.
Modified:
nixos/trunk/modules/tasks/filesystems.nix
Modified: nixos/trunk/modules/tasks/filesystems.nix
==============================================================================
--- nixos/trunk/modules/tasks/filesystems.nix Tue May 15 22:12:27 2012
(r34132)
+++ nixos/trunk/modules/tasks/filesystems.nix Wed May 16 00:03:44 2012
(r34133)
@@ -15,7 +15,7 @@
+ " " + fs.fsType
+ " " + fs.options
+ " 0"
- + " " + (if fs.fsType == "none" || fs.noCheck then "0" else
+ + " " + (if fs.fsType == "none" || fs.fsType == "btrfs" ||
fs.noCheck then "0" else
if fs.mountPoint == "/" then "1" else "2")
+ "\n"
)}
@@ -117,6 +117,17 @@
'';
};
+ autoFormat = mkOption {
+ default = false;
+ type = types.bool;
+ description = ''
+ If the device does not currently contain a filesystem (as
+ determined by <command>blkid</command>, then automatically
+ format it with the filesystem type specified in
+ <option>fsType</option>. Use with caution.
+ '';
+ };
+
noCheck = mkOption {
default = false;
type = types.bool;
@@ -186,6 +197,17 @@
# ${fstab}
echo "mounting filesystems..."
+ # Format devices.
+ ${flip concatMapStrings config.fileSystems (fs: optionalString
fs.autoFormat ''
+ if [ -e "${fs.device}" ]; then
+ 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}"
+ fi
+ fi
+ '')}
+
# Create missing mount points. Note that this won't work
# if the mount point is under another mount point.
${flip concatMapStrings config.fileSystems (fs: optionalString
fs.autocreate ''
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits