ext4fs.nix (884B)
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 == "ext4") { 16 kernel.config = { 17 EXT4_FS = "y"; 18 EXT4_USE_FOR_EXT2 = "y"; 19 FS_ENCRYPTION = "y"; 20 }; 21 boot.initramfs.enable = true; 22 system.outputs = { 23 rootfs = 24 let 25 inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs; 26 in 27 runCommand "mkfs.ext4" 28 { 29 depsBuildBuild = [ e2fsprogs ]; 30 } 31 '' 32 tree=${o.bootablerootdir} 33 size=$(du -s --apparent-size --block-size 1024 $tree |cut -f1) 34 # add 25% for filesystem overhead 35 size=$(( 5 * $size / 4)) 36 dd if=/dev/zero of=$out bs=1024 count=$size 37 mke2fs -t ext4 -j -d $tree $out 38 ''; 39 }; 40 }; 41 }