jffs2.nix (991B)
1 { 2 config 3 , pkgs 4 , lib 5 , ... 6 }: 7 let 8 inherit (lib) mkIf mkOption types; 9 o = config.system.outputs; 10 in 11 { 12 imports = [ 13 ./initramfs.nix 14 ]; 15 16 config = mkIf (config.rootfsType == "jffs2") { 17 kernel.config = { 18 JFFS2_FS = "y"; 19 JFFS2_LZO = "y"; 20 JFFS2_RTIME = "y"; 21 JFFS2_COMPRESSION_OPTIONS = "y"; 22 JFFS2_ZLIB = "y"; 23 JFFS2_CMODE_SIZE = "y"; 24 }; 25 boot.initramfs.enable = true; 26 system.outputs = { 27 rootfs = 28 let 29 inherit (pkgs.pkgsBuildBuild) runCommand mtdutils; 30 endian = if pkgs.stdenv.isBigEndian 31 then "--big-endian" else "--little-endian"; 32 in runCommand "make-jffs2" { 33 depsBuildBuild = [ mtdutils ]; 34 } '' 35 tree=${o.bootablerootdir} 36 (cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime ) 37 ''; 38 }; 39 }; 40 }