commit 42725f56f9653f3998a684775e08d348b212556c
parent 63a89f7d0de5fdd135801bb0bc3711cd8434b27f
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 10 Apr 2023 19:59:09 +0100
make jffs2 module provide o.rootfs, conditionally
it's enabled if config.rootfsType == "jffs2"
Diffstat:
5 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/modules/base.nix b/modules/base.nix
@@ -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 = {
diff --git a/modules/jffs2.nix b/modules/jffs2.nix
@@ -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
diff --git a/modules/outputs.nix b/modules/outputs.nix
@@ -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
diff --git a/modules/squashfs.nix b/modules/squashfs.nix
@@ -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;
+ };
+ };
+}
diff --git a/tests/jffs2/configuration.nix b/tests/jffs2/configuration.nix
@@ -4,4 +4,5 @@
../../vanilla-configuration.nix
../../modules/jffs2.nix
];
+ config.rootfsType = "jffs2";
}