2023-10-16 20:55:17 +02:00
|
|
|
{
|
|
|
|
config
|
|
|
|
, pkgs
|
|
|
|
, lib
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (lib) mkIf mkOption types;
|
2023-12-05 18:29:01 +01:00
|
|
|
o = config.system.outputs;
|
2023-10-16 20:55:17 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./initramfs.nix
|
|
|
|
];
|
2023-12-04 14:11:53 +01:00
|
|
|
|
|
|
|
options.system.outputs.rootubifs = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
internal = true;
|
|
|
|
};
|
|
|
|
|
2023-10-16 20:55:17 +02:00
|
|
|
options.hardware.ubi = {
|
|
|
|
minIOSize = mkOption { type = types.str; };
|
2023-12-04 14:11:53 +01:00
|
|
|
logicalEraseBlockSize = mkOption { type = types.str; }; # LEB
|
|
|
|
physicalEraseBlockSize = mkOption { type = types.str; }; # PEB
|
2023-10-16 20:55:17 +02:00
|
|
|
maxLEBcount = mkOption { type = types.str; }; # LEB
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (config.rootfsType == "ubifs") {
|
|
|
|
kernel.config = {
|
|
|
|
MTD_UBI="y";
|
|
|
|
UBIFS_FS = "y";
|
|
|
|
UBIFS_FS_SECURITY = "n";
|
|
|
|
};
|
|
|
|
boot.initramfs.enable = true;
|
2023-12-05 18:29:01 +01:00
|
|
|
system.outputs = {
|
2023-10-16 20:55:17 +02:00
|
|
|
rootfs =
|
|
|
|
let
|
|
|
|
inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
|
|
|
|
cfg = config.hardware.ubi;
|
|
|
|
in runCommand "mkfs.ubifs" {
|
|
|
|
depsBuildBuild = [ mtdutils ];
|
|
|
|
} ''
|
2023-12-05 18:29:01 +01:00
|
|
|
mkdir tmp
|
2023-12-11 21:49:48 +01:00
|
|
|
tree=${o.bootablerootdir}
|
2023-12-04 14:11:53 +01:00
|
|
|
mkfs.ubifs -x favor_lzo -c ${cfg.maxLEBcount} -m ${cfg.minIOSize} -e ${cfg.logicalEraseBlockSize} -y -r $tree --output $out --squash-uids -o $out
|
2023-10-16 20:55:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|