btrfs.nix (875B)
1 { 2 config, 3 pkgs, 4 lib, 5 ... 6 }: 7 let 8 inherit (lib) mkIf; 9 o = config.system.outputs; 10 in 11 { 12 imports = [ 13 ./initramfs.nix 14 ]; 15 config = mkIf (config.rootfsType == "btrfs") { 16 kernel.config = { 17 BTRFS_FS = "y"; 18 }; 19 boot.initramfs.enable = true; 20 system.outputs = { 21 rootfs = 22 let 23 inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs; 24 in 25 runCommand "mkfs.btrfs" 26 { 27 depsBuildBuild = [ e2fsprogs ]; 28 } 29 '' 30 tree=${o.bootablerootdir} 31 size=$(du -s --apparent-size --block-size 1024 $tree |cut -f1) 32 # add 25% for filesystem overhead 33 size=$(( 5 * $size / 4)) 34 dd if=/dev/zero of=$out bs=1024 count=$size 35 echo "not implemented" ; exit 1 36 # mke2fs -t ext4 -j -d $tree $out 37 ''; 38 }; 39 }; 40 }