1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 inInitrd = any (fs: fs == "f2fs") config.boot.initrd.supportedFilesystems;
7 fileSystems = filter (x: x.fsType == "f2fs") config.system.build.fileSystems;
8in
9{
10 config = mkIf (any (fs: fs == "f2fs") config.boot.supportedFilesystems) {
11
12 system.fsPackages = [ pkgs.f2fs-tools ];
13
14 boot.initrd.availableKernelModules = mkIf inInitrd [ "f2fs" "crc32" ];
15
16 boot.initrd.extraUtilsCommands = mkIf (inInitrd && !config.boot.initrd.systemd.enable) ''
17 copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/fsck.f2fs
18 ${optionalString (any (fs: fs.autoResize) fileSystems) ''
19 # We need f2fs-tools' tools to resize filesystems
20 copy_bin_and_libs ${pkgs.f2fs-tools}/sbin/resize.f2fs
21 ''}
22
23 '';
24 };
25}