{
  config,
  lib,
  namespace,
  ...
}:
with lib;
let
  cfg = config.${namespace}.bootloader.lanzaboote;
  inherit (lib.${namespace}) mkOpt;
in
{
  options.${namespace}.bootloader.lanzaboote = {
    enable = mkEnableOption "enable lanzaboote";

    configLimit = mkOpt types.int 10 "Number of boot items to keep";
  };

  config = mkIf cfg.enable {
    boot = {
      loader = {
        efi = {
          canTouchEfiVariables = true;
          efiSysMountPoint = "/boot";
        };
      };
      lanzaboote = {
        enable = cfg.enable;
        pkiBundle = "/etc/secureboot";
        settings = {
          console-mode = "max";
        };
        configurationLimit = cfg.configLimit;
      };
    };
  };
}
