liminix

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

ubifs.nix (1185B)


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