liminix

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

ubifs.nix (999B)


      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   options.hardware.ubi = {
     16     minIOSize = mkOption { type = types.str; };
     17     eraseBlockSize = mkOption { type = types.str; }; # LEB
     18     maxLEBcount = mkOption { type = types.str; }; # LEB
     19   };
     20 
     21   config = mkIf (config.rootfsType == "ubifs") {
     22     kernel.config = {
     23       MTD_UBI="y";
     24       UBIFS_FS = "y";
     25       UBIFS_FS_SECURITY = "n";
     26     };
     27     boot.initramfs.enable = true;
     28     system.outputs = {
     29       rootfs =
     30         let
     31           inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
     32           cfg = config.hardware.ubi;
     33         in runCommand "mkfs.ubifs" {
     34           depsBuildBuild = [ mtdutils ];
     35         } ''
     36           mkdir tmp
     37           tree=${o.bootablerootdir}
     38           mkfs.ubifs -x favor_lzo -c ${cfg.maxLEBcount} -m ${cfg.minIOSize} -e ${cfg.eraseBlockSize}  -y -r $tree --output $out  --squash-uids -o $out
     39         '';
     40     };
     41   };
     42 }