summary refs log tree commit diff
path: root/modules/tasks
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2012-03-08 21:07:25 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2012-03-08 21:07:25 +0000
commit9d1b72a6c74140099235f408f559256fc95cc386 (patch)
treedf54864fc8059dd038ea61751b673eecda1ee286 /modules/tasks
parent98dde1378290ea87389c1caa5285b398fc5e396f (diff)
downloadnixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar.gz
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar.bz2
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar.lz
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar.xz
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.tar.zst
nixpkgs-9d1b72a6c74140099235f408f559256fc95cc386.zip
Making nixos fileSystems aware of fsType "reiserfs" and "btrfs", regarding
modules, tools, intrd pieces, ...

That's only useful if the user specifies fsType, though.


svn path=/nixos/trunk/; revision=32912
Diffstat (limited to 'modules/tasks')
-rw-r--r--modules/tasks/filesystems.nix33
1 files changed, 29 insertions, 4 deletions
diff --git a/modules/tasks/filesystems.nix b/modules/tasks/filesystems.nix
index 614d4415062..59e1137852a 100644
--- a/modules/tasks/filesystems.nix
+++ b/modules/tasks/filesystems.nix
@@ -3,12 +3,33 @@
 with pkgs.lib;
 
 let
-  needsBtrfsProgs = any (fs: fs.fsType == "btrfs") config.fileSystems;
+  usingSome = fsname: any (fs: fs.fsType == fsname) config.fileSystems;
+  usingSomeStage1 =  fsname: any (fs: fs.fsType == fsname &&
+    (fs.mountPoint == "/" || fs.neededForBoot)) config.fileSystems;
+
+  usingBtrfs = usingSome "btrfs";
+  usingBtrfsStage1 = usingSomeStage1 "btrfs";
+
+  usingReiserfs = usingSome "reiserfs";
+  usingReiserfsStage1 = usingSomeStage1 "reiserfs";
 
   # Packages that provide fsck backends.
-  fsPackages = [ pkgs.e2fsprogs pkgs.reiserfsprogs pkgs.dosfstools ]
-             ++ optional needsBtrfsProgs pkgs.btrfsProgs;
+  fsPackages = [ pkgs.e2fsprogs pkgs.dosfstools ]
+    ++ optional usingReiserfs pkgs.btrfsProgs
+    ++ optional usingBtrfs pkgs.btrfsProgs;
+
+  fsKernelModules = optional usingBtrfsStage1 [ "btrfs" "crc32c" ]
+    ++ optional usingReiserfsStage1 [ "reiserfs" ];
 
+  fsExtraUtilsCommands = optionalString usingBtrfsStage1 ''
+      cp -v ${pkgs.btrfsProgs}/bin/btrfsck $out/bin
+      cp -v ${pkgs.btrfsProgs}/bin/btrfs $out/bin
+      ln -sv btrfsck $out/bin/fsck.btrfs
+    '';
+
+  fsPostDeviceCommands = optionalString usingBtrfsStage1 ''
+    btrfs device scan
+  '';
 
 in
 
@@ -162,6 +183,10 @@ in
         target = "fstab";
       };
 
+    boot.initrd.extraUtilsCommands = fsExtraUtilsCommands;
+    boot.initrd.postDeviceCommands = fsPostDeviceCommands;
+    boot.initrd.kernelModules = fsKernelModules;
+
     jobs.mountall =
       { startOn = "started udev"
           # !!! The `started nfs-kernel-statd' condition shouldn't be
@@ -178,7 +203,7 @@ in
             exec > /dev/console 2>&1
             echo "mounting filesystems..."
             export PATH=${config.system.sbin.mount}/bin:${makeSearchPath "sbin" ([pkgs.utillinux] ++ fsPackages)}:$PATH
-            ${optionalString needsBtrfsProgs "${pkgs.btrfsProgs}/bin/btrfs device scan"}
+            ${optionalString usingBtrfs "${pkgs.btrfsProgs}/bin/btrfs device scan"}
             ${pkgs.mountall}/sbin/mountall
           '';
       };