1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9
10 hasExtX = s: s.ext2 or s.ext3 or s.ext4 or false;
11
12 inInitrd = hasExtX config.boot.initrd.supportedFilesystems;
13 inSystem = hasExtX config.boot.supportedFilesystems;
14
15in
16
17{
18 config = {
19
20 system.fsPackages = lib.mkIf (config.boot.initrd.systemd.enable -> (inInitrd || inSystem)) [
21 pkgs.e2fsprogs
22 ];
23
24 # As of kernel 4.3, there is no separate ext3 driver (they're also handled by ext4.ko)
25 boot.initrd.availableKernelModules = lib.mkIf (config.boot.initrd.systemd.enable -> inInitrd) [
26 "ext2"
27 "ext4"
28 ];
29
30 boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
31 # Copy e2fsck and friends.
32 copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/e2fsck
33 copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/tune2fs
34 ln -sv e2fsck $out/bin/fsck.ext2
35 ln -sv e2fsck $out/bin/fsck.ext3
36 ln -sv e2fsck $out/bin/fsck.ext4
37 '';
38
39 boot.initrd.systemd.initrdBin = lib.mkIf inInitrd [ pkgs.e2fsprogs ];
40
41 };
42}