summaryrefslogtreecommitdiff
path: root/modules/nixos/mixins/lanzaboote.nix
blob: c55fa192978f2bc2c4a446b49ecd8dafa27eb67b (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
38
39
40
41
42
43
{
  config,
  lib,
  pkgs,
  inputs,
  ...
}:

let
  cfg = config.boot.lanzaboote;
in

{
  imports = [ inputs.lanzaboote.nixosModules.lanzaboote ];

  config = lib.mkMerge [
    {
      boot.lanzaboote = {
        pkiBundle = "/etc/secureboot";

        settings = {
          console-mode = "auto";
          editor = false;
          timeout = 0;
        };
      };
    }

    (lib.mkIf cfg.enable {
      boot = {
        initrd.systemd.enable = true; # For unlocking LUKS root with TPM2
        loader.systemd-boot.enable = lib.mkForce false; # Lanzaboote replaces this
      };

      environment.systemPackages = [
        # manual Lanzaboote maintenance (NOTE: I have not actually used this since ~2022)
        pkgs.sbctl
        # TODO: Is this actually required for using `tpm2-device=auto` to unlock LUKS volumes in initrd? Probably
        pkgs.tpm2-tss
      ];
    })
  ];
}