422f3edab1
This adds a simple boot blessing module, to be used, with the Zyxel NWA50AX. There's a lot of elephant in the rooms: how do you upgrade kernel, etc. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
33 lines
1,005 B
Nix
33 lines
1,005 B
Nix
{
|
|
liminix
|
|
, lib
|
|
, zyxel-bootconfig
|
|
}:
|
|
{ ensureActiveImage, primaryMtdPartition, secondaryMtdPartition, bootConfigurationMtdPartition, kernelCommandLineSource }:
|
|
let
|
|
inherit (liminix.services) oneshot;
|
|
activeImageIndex = if ensureActiveImage == "primary" then 0 else 1;
|
|
in oneshot {
|
|
name = "zyxel-boot-configure";
|
|
up = ''
|
|
set -- $(cat /proc/device-tree/chosen/bootargs)
|
|
for x in "$@"; do
|
|
case "$x" in
|
|
bootImage=*)
|
|
BOOT_IMAGE="''${x#bootImage=}"
|
|
echo "Current boot image is $BOOT_IMAGE."
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if test -z "$BOOT_IMAGE"; then
|
|
echo "No valid image was provided in the kernel command line."
|
|
exit 1
|
|
else
|
|
${lib.getExe zyxel-bootconfig} ${bootConfigurationMtdPartition} set-image-status "$BOOT_IMAGE" valid
|
|
${lib.getExe zyxel-bootconfig} ${bootConfigurationMtdPartition} set-active-image ${toString activeImageIndex}
|
|
|
|
echo "Active image is now ${ensureActiveImage}"
|
|
fi
|
|
'';
|
|
}
|