nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix

36 lines
743 B
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
inInitrd = any (fs: fs == "btrfs") config.boot.initrd.supportedFilesystems;
in
{
config = mkIf (any (fs: fs == "btrfs") config.boot.supportedFilesystems) {
2016-01-03 18:21:27 +00:00
system.fsPackages = [ pkgs.btrfs-progs ];
boot.initrd.kernelModules = mkIf inInitrd [ "btrfs" "crc32c" ];
boot.initrd.extraUtilsCommands = mkIf inInitrd
''
2016-01-03 18:21:27 +00:00
copy_bin_and_libs ${pkgs.btrfs-progs}/bin/btrfs
ln -sv btrfs $out/bin/btrfsck
ln -sv btrfsck $out/bin/fsck.btrfs
'';
boot.initrd.extraUtilsCommandsTest = mkIf inInitrd
''
$out/bin/btrfs --version
'';
boot.initrd.postDeviceCommands = mkIf inInitrd
''
btrfs device scan
'';
};
}