blob: 7054efaaac6601f938c71c3030a9a3607f0d7afa (
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
|
{
config,
lib,
modulesPath,
pkgs,
...
}:
{
imports = [ (modulesPath + "/profiles/all-hardware.nix") ];
options.usbauth = lib.mkOption {
description = "USB Auth";
type = lib.types.submodule {
options = {
enable = lib.mkOption { type = lib.types.bool; default = false; };
device = lib.mkOption { type = lib.types.str; };
keyname = lib.mkOption { type = lib.types.str; };
uuid = lib.mkOption { type = lib.types.str; };
};
};
};
config = lib.mkIf config.usbauth.enable {
boot.initrd.systemd.services.usb-auth-setup = {
description = "USBAuth Setup";
before = [ "cryptsetup-pre.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash ${./usbauth.sh} ${config.usbauth.uuid}";
};
wantedBy = [ "sysinit.target" ];
};
boot.initrd.luks.devices."${config.usbauth.device}" = {
keyFile = "/key/.keys/${config.usbauth.keyname}";
};
};
}
|