at 16.09-beta 743 B view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 inInitrd = any (fs: fs == "btrfs") config.boot.initrd.supportedFilesystems; 8 9in 10 11{ 12 config = mkIf (any (fs: fs == "btrfs") config.boot.supportedFilesystems) { 13 14 system.fsPackages = [ pkgs.btrfs-progs ]; 15 16 boot.initrd.kernelModules = mkIf inInitrd [ "btrfs" "crc32c" ]; 17 18 boot.initrd.extraUtilsCommands = mkIf inInitrd 19 '' 20 copy_bin_and_libs ${pkgs.btrfs-progs}/bin/btrfs 21 ln -sv btrfs $out/bin/btrfsck 22 ln -sv btrfsck $out/bin/fsck.btrfs 23 ''; 24 25 boot.initrd.extraUtilsCommandsTest = mkIf inInitrd 26 '' 27 $out/bin/btrfs --version 28 ''; 29 30 boot.initrd.postDeviceCommands = mkIf inInitrd 31 '' 32 btrfs device scan 33 ''; 34 }; 35}