summaryrefslogtreecommitdiff
path: root/sys/boot/sb.nix
blob: bdf7f0fa78ce2aa0105485f3feb03bd7ef630d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, pkgs, ... }:
with lib; let
  cfg = config.local.boot.secureBoot;
in
{
  options.local.boot.secureBoot = {
    enable = mkEnableOption "secure boot";
  };

  config = mkIf cfg.enable {
    assertions = [
      {
        assertion = config.local.boot.efi.enable;
        message = "secure boot requires EFI";
      }
      {
        assertion = config.local.boot.loader == "systemd-boot";
        message = "lanzaboote requires systemd-boot";
      }
    ];

    boot = {
      loader.systemd-boot.enable = mkForce false;

      lanzaboote = {
        enable = true;
        pkiBundle = "/etc/secureboot";
      };
    };

    environment.systemPackages = [
      pkgs.sbctl
    ];

    local.boot.impermanence.directories = [ "/etc/secureboot" ];
  };
}