make jffs2 module provide o.rootfs, conditionally

it's enabled if config.rootfsType == "jffs2"
This commit is contained in:
Daniel Barlow 2023-04-10 19:59:09 +01:00
parent 63a89f7d0d
commit 42725f56f9
5 changed files with 33 additions and 6 deletions

View file

@ -25,6 +25,10 @@ in {
type = types.attrsOf type_service;
};
filesystem = mkOption { type = types.anything; };
rootfsType = mkOption {
default = "squashfs";
type = types.str;
};
kernel = {
src = mkOption { type = types.package; } ;
extraPatchPhase = mkOption {
@ -107,7 +111,8 @@ in {
};
};
boot.commandLine = [
"console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8 rootfstype=squashfs"
"console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8"
"rootfstype=${config.rootfsType}"
"fw_devlink=off"
];
users.root = {

View file

@ -1,22 +1,24 @@
{
config
, pkgs
, lib
, ...
}:
let
inherit (pkgs) closureInfo;
inherit (lib) mkIf;
in
{
imports = [
./initramfs.nix
];
config = {
config = mkIf (config.rootfsType == "jffs2") {
kernel.config.JFFS2_FS = "y";
boot.initramfs.enable = true;
outputs = rec {
systemConfiguration =
pkgs.pkgsBuildBuild.systemconfig config.filesystem.contents;
jffs2fs =
rootfs =
let
inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
endian = if pkgs.stdenv.isBigEndian
@ -38,7 +40,7 @@ in
pkgs.runCommand "jffs2boot" {} ''
mkdir $out
cd $out
ln -s ${o.jffs2fs} rootfs
ln -s ${o.rootfs} rootfs
ln -s ${o.kernel} vmlinux
ln -s ${o.manifest} manifest
ln -s ${o.initramfs} initramfs

View file

@ -9,6 +9,9 @@ let
inherit (pkgs) liminix callPackage writeText;
in
{
imports = [
./squashfs.nix
];
options = {
outputs = mkOption {
type = types.attrsOf types.package;
@ -17,7 +20,6 @@ in
};
config = {
outputs = rec {
rootfs = liminix.builders.squashfs config.filesystem.contents;
tftpd = pkgs.buildPackages.tufted;
kernel = liminix.builders.kernel.override {
inherit (config.kernel) config src extraPatchPhase;
@ -38,7 +40,7 @@ in
vmroot = pkgs.runCommand "qemu" {} ''
mkdir $out
cd $out
ln -s ${rootfs} rootfs
ln -s ${config.outputs.rootfs} rootfs
ln -s ${kernel} vmlinux
ln -s ${manifest} manifest
ln -s ${kernel.headers} build

17
modules/squashfs.nix Normal file
View file

@ -0,0 +1,17 @@
{
config
, pkgs
, lib
, ...
}:
let
inherit (pkgs) liminix;
inherit (lib) mkIf;
in
{
config = mkIf (config.rootfsType == "squashfs") {
outputs = rec {
rootfs = liminix.builders.squashfs config.filesystem.contents;
};
};
}

View file

@ -4,4 +4,5 @@
../../vanilla-configuration.nix
../../modules/jffs2.nix
];
config.rootfsType = "jffs2";
}