initrd: Add configuration file for boot/init
This allows a single boot/init build to be re-used across devices, and
more importantly, across rebuilds when only configuration changes.
This also removes the need to hardcode some annoying paths that are
better served through configuration, to their natural store paths.
@@ -7,11 +7,22 @@ let
mkExtraUtils
runCommandNoCC
udev
+ writeText
+ ;
+ inherit (lib)
+ flatten
+ optionalString
+ optionals
+ ;
+ inherit (builtins)
+ toJSON
;
- inherit (lib) flatten optionals optionalString;
initWrapperRealInit = "/actual-init";
+ # FIXME : less hardcoding of what goes in the config...
+ cfg_kernel = config.mobile.boot.stage-1.kernel;
+
# TODO: define as an option
# This is a bit buggy:
# * fast burst of \n-delimited output will not work as expected
@@ -61,6 +72,21 @@ let
exec ${optionalString withStrace "${extraUtils}/bin/strace -f"} ${initWrapperRealInit}
'';
+ bootConfig = {
+ device = {
+ inherit (device_config) name;
+ };
+ kernel = {
+ inherit (cfg_kernel) modules;
+ };
+ root = {
+ inherit (config.fileSystems."/") device;
+ };
+
+ };
+
+ bootConfigFile = writeText "${device_name}-boot-config" (toJSON bootConfig);
+
contents =
(optionals (stage-1 ? contents) (flatten stage-1.contents))
++ [
@@ -68,6 +94,9 @@ let
# FIXME: Do we care?
#{ object = "${extraUtils}/bin/sh"; symlink = "/bin/sh"; }
+ # The mostly device-specific configuration for the bootloader.
+ { object = bootConfigFile; symlink = "/etc/boot/config"; }
+
# FIXME: udev/udevRules module.
{ object = udevRules; symlink = "/etc/udev/rules.d"; }
]
