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