liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

jffs2.nix (998B)


      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 
     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 then "--big-endian" else "--little-endian";
     31         in
     32         runCommand "make-jffs2"
     33           {
     34             depsBuildBuild = [ mtdutils ];
     35           }
     36           ''
     37             tree=${o.bootablerootdir}
     38             (cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime )
     39           '';
     40     };
     41   };
     42 }