From 9d89ca0c03a669a81f4e98aa6fbf2606cea15ff7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 Mar 2012 16:17:37 +0000 Subject: [PATCH] * Modularise vfat support. Also add fsck.vfat to the initrd. This prevents errors when booting from VFAT (e.g. an ISO image converted using unetbootin). svn path=/nixos/trunk/; revision=32956 --- modules/installer/cd-dvd/iso-image.nix | 5 +++++ modules/module-list.nix | 1 + modules/profiles/all-hardware.nix | 4 ---- modules/profiles/base.nix | 2 +- modules/tasks/filesystems/vfat.nix | 25 +++++++++++++++++++++++++ 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 modules/tasks/filesystems/vfat.nix diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix index 0a2f76c919c..7cc08315d01 100644 --- a/modules/installer/cd-dvd/iso-image.nix +++ b/modules/installer/cd-dvd/iso-image.nix @@ -259,4 +259,9 @@ in touch /etc/NIXOS ${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /var/run/current-system ''; + + # Add vfat support to the initrd to enable people to copy the + # contents of the CD to a bootable USB stick. + boot.initrd.supportedFilesystems = [ "vfat" ]; + } diff --git a/modules/module-list.nix b/modules/module-list.nix index 5a1459f5226..b69295a89da 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -203,6 +203,7 @@ ./tasks/filesystems/ext.nix ./tasks/filesystems/nfs.nix ./tasks/filesystems/reiserfs.nix + ./tasks/filesystems/vfat.nix ./tasks/kbd.nix ./tasks/lvm.nix ./tasks/network-interfaces.nix diff --git a/modules/profiles/all-hardware.nix b/modules/profiles/all-hardware.nix index 8b894fa4df0..041948aa462 100644 --- a/modules/profiles/all-hardware.nix +++ b/modules/profiles/all-hardware.nix @@ -41,10 +41,6 @@ # Virtio (QEMU, KVM etc.) support. "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "virtio_console" - - # Add vfat to enable people to copy the contents of the CD to a - # bootable USB stick. - "vfat" "nls_cp437" "nls_iso8859-1" ]; boot.initrd.kernelModules = diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index d6412e09a5f..75a58f8568a 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -51,6 +51,6 @@ ]; # Include support for various filesystems. - boot.supportedFilesystems = [ "btrfs" "reiserfs" ]; + boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" ]; } diff --git a/modules/tasks/filesystems/vfat.nix b/modules/tasks/filesystems/vfat.nix new file mode 100644 index 00000000000..5ca72f142b7 --- /dev/null +++ b/modules/tasks/filesystems/vfat.nix @@ -0,0 +1,25 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + + inInitrd = any (fs: fs == "vfat") config.boot.initrd.supportedFilesystems; + +in + +{ + config = mkIf (any (fs: fs == "vfat") config.boot.supportedFilesystems) { + + system.fsPackages = [ pkgs.dosfstools ]; + + boot.initrd.kernelModules = mkIf inInitrd [ "vfat" "nls_cp437" "nls_iso8859-1" ]; + + boot.initrd.extraUtilsCommands = mkIf inInitrd + '' + cp -v ${pkgs.dosfstools}/sbin/dosfsck $out/bin + ln -sv dosfsck $out/bin/fsck.vfat + ''; + + }; +}