blob: 1e4d171d61f34a784d3a128e4a8c037f0df6a593 (
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
44
45
46
47
48
49
50
51
|
{
inputs,
lib,
pkgs,
...
}:
{
imports = [
inputs.lanzaboote.nixosModules.lanzaboote
];
environment.systemPackages = [
pkgs.sbctl
];
# Lanzaboote currently replaces the systemd-boot module.
# This setting is usually set to true in configuration.nix
# generated at installation time. So we force it to false
# for now.
boot.loader.systemd-boot.enable = lib.mkForce false;
boot.lanzaboote = {
enable = true;
pkiBundle = "/var/lib/sbctl";
};
# Create and enroll Secure Boot keys on first boot
systemd.services.sbctl-setup = {
description = "Create and enroll Secure Boot keys";
wantedBy = [ "multi-user.target" ];
unitConfig.ConditionPathExists = "!/var/lib/sbctl/GUID";
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
script = ''
echo "Creating Secure Boot keys..."
${pkgs.sbctl}/bin/sbctl create-keys
# Check if we're in Setup Mode
if ${pkgs.sbctl}/bin/sbctl status | grep -q "Setup Mode"; then
echo "UEFI is in Setup Mode, enrolling keys..."
${pkgs.sbctl}/bin/sbctl enroll-keys --microsoft
else
echo "WARNING: UEFI is not in Setup Mode. Please clear Secure Boot keys in UEFI and reboot."
fi
'';
};
}
|