2023-04-05 00:35:49 +02:00
|
|
|
{
|
|
|
|
config
|
|
|
|
, pkgs
|
2023-04-10 20:59:09 +02:00
|
|
|
, lib
|
2023-04-05 00:35:49 +02:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
let
|
2023-07-13 20:24:59 +02:00
|
|
|
inherit (lib) mkIf mkOption types;
|
2023-12-05 18:29:01 +01:00
|
|
|
o = config.system.outputs;
|
2023-04-05 00:35:49 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./initramfs.nix
|
|
|
|
];
|
2023-07-13 20:24:59 +02:00
|
|
|
|
2023-04-10 20:59:09 +02:00
|
|
|
config = mkIf (config.rootfsType == "jffs2") {
|
2023-04-15 18:23:58 +02:00
|
|
|
kernel.config = {
|
|
|
|
JFFS2_FS = "y";
|
|
|
|
JFFS2_LZO = "y";
|
|
|
|
JFFS2_RTIME = "y";
|
|
|
|
JFFS2_COMPRESSION_OPTIONS = "y";
|
|
|
|
JFFS2_ZLIB = "y";
|
|
|
|
JFFS2_CMODE_SIZE = "y";
|
|
|
|
};
|
2023-04-10 20:07:27 +02:00
|
|
|
boot.initramfs.enable = true;
|
2023-12-05 18:29:01 +01:00
|
|
|
system.outputs = {
|
2023-04-10 20:59:09 +02:00
|
|
|
rootfs =
|
2023-04-05 00:35:49 +02:00
|
|
|
let
|
2023-04-07 10:39:47 +02:00
|
|
|
inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
|
|
|
|
endian = if pkgs.stdenv.isBigEndian
|
|
|
|
then "--big-endian" else "--little-endian";
|
2023-04-05 00:35:49 +02:00
|
|
|
in runCommand "make-jffs2" {
|
|
|
|
depsBuildBuild = [ mtdutils ];
|
|
|
|
} ''
|
2023-12-11 21:49:48 +01:00
|
|
|
tree=${o.bootablerootdir}
|
|
|
|
(cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime )
|
2023-04-05 00:35:49 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|