2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2012-03-09 15:37:58 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2012-03-09 15:37:58 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inInitrd = any (fs: fs == "btrfs") config.boot.initrd.supportedFilesystems;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
config = mkIf (any (fs: fs == "btrfs") config.boot.supportedFilesystems) {
|
|
|
|
|
|
|
|
system.fsPackages = [ pkgs.btrfsProgs ];
|
|
|
|
|
|
|
|
boot.initrd.kernelModules = mkIf inInitrd [ "btrfs" "crc32c" ];
|
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommands = mkIf inInitrd
|
|
|
|
''
|
2013-05-13 23:07:58 +02:00
|
|
|
mkdir -p $out/bin
|
2012-03-09 15:37:58 +01:00
|
|
|
cp -v ${pkgs.btrfsProgs}/bin/btrfs $out/bin
|
2013-05-13 23:07:58 +02:00
|
|
|
ln -sv btrfs $out/bin/btrfsck
|
|
|
|
ln -sv btrfsck $out/bin/fsck.btrfs
|
2013-05-13 20:16:53 +02:00
|
|
|
# !!! Increases uncompressed initrd by 240k
|
2013-05-15 05:35:10 +02:00
|
|
|
cp -pv ${pkgs.zlib}/lib/libz.so* $out/lib
|
|
|
|
cp -pv ${pkgs.lzo}/lib/liblzo2.so* $out/lib
|
2012-03-09 15:37:58 +01:00
|
|
|
'';
|
|
|
|
|
2013-05-13 20:07:38 +02:00
|
|
|
boot.initrd.extraUtilsCommandsTest = mkIf inInitrd
|
|
|
|
''
|
|
|
|
$out/bin/btrfs --version
|
|
|
|
'';
|
|
|
|
|
2012-03-09 15:37:58 +01:00
|
|
|
boot.initrd.postDeviceCommands = mkIf inInitrd
|
|
|
|
''
|
|
|
|
btrfs device scan
|
|
|
|
'';
|
|
|
|
|
|
|
|
# !!! This is broken. There should be a udev rule to do this when
|
|
|
|
# new devices are discovered.
|
|
|
|
jobs.udev.postStart =
|
|
|
|
''
|
|
|
|
${pkgs.btrfsProgs}/bin/btrfs device scan
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|