liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (2391B)


      1 ## Boot blessing via Zyxel
      2 ## =======================
      3 ## Boot blessing is the process to bless a particular boot configuration
      4 ## It is commonly encountered in devices with redundant partitions
      5 ## for automatic recovery of broken upgrades.
      6 ## This is also known as A/B schemas, where A represents the primary partition
      7 ## and B the secondary partition used for recovery.
      8 ## To use boot blessing on Liminix, you need to have the support of
      9 ## your bootloader to help you boot on the secondary partition in case of
     10 ## failure on the primary partition. The exact details are specifics to your device.
     11 ## See the Zyxel NWA50AX for an example.
     12 ## TODO: generalize this module.
     13 {
     14   config,
     15   lib,
     16   pkgs,
     17   ...
     18 }:
     19 let
     20   inherit (lib) mkOption types;
     21   inherit (pkgs) liminix;
     22 in
     23 {
     24   options.boot.zyxel-dual-image = mkOption {
     25     type = liminix.lib.types.serviceDefn;
     26   };
     27 
     28   config.boot.zyxel-dual-image = config.system.callService ./service.nix {
     29     ensureActiveImage = mkOption {
     30       type = types.enum [
     31         "primary"
     32         "secondary"
     33       ];
     34       default = "primary";
     35       description = ''
     36         At boot, ensure that the active image is the one specified.
     37 
     38                 If you are already on a broken image, you need to manually boot
     39                 into the right image via `atgo <image index>` in U-Boot.
     40       '';
     41     };
     42 
     43     kernelCommandLineSource = mkOption {
     44       type = types.enum [
     45         "/proc/cmdline"
     46         "/proc/device-tree/chosen/bootargs"
     47       ];
     48       default = "/proc/device-tree/chosen/bootargs";
     49       description = ''
     50         Kernel command line arguments source file.
     51                 On MIPS, Liminix embeds the kernel command line in /proc/device-tree/chosen/bootargs-override.
     52 
     53                 In this instance, it does not get concatenated with `/proc/cmdline`.
     54                 Therefore you may prefer to source it from another place, like `/proc/device-tree/chosen/bootargs`.
     55       '';
     56     };
     57 
     58     primaryMtdPartition = mkOption {
     59       type = types.str;
     60       description = "Primary MTD partition device node, i.e. for image 0.";
     61     };
     62 
     63     secondaryMtdPartition = mkOption {
     64       type = types.str;
     65       description = "Secondary MTD partition device node, i.e. for image 1.";
     66     };
     67 
     68     bootConfigurationMtdPartition = mkOption {
     69       type = types.str;
     70       description = "Boot configuration MTD partition device node.";
     71     };
     72   };
     73 }