blob: 7f7c24e70c3bbaaa38455eb4d5e4d3a4459cf98e (
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
|
{
config,
lib,
pkgs,
...
}:
with lib; let
cnf = config.cynerd.autounlock;
in {
options = {
cynerd.autounlock = mkOption {
type = with types; attrsOf string;
default = {};
description = "Devices to be auto-unlocked.";
};
};
config = mkIf (cnf != {}) {
environment.systemPackages = [pkgs.luks-hw-password];
boot.initrd = {
extraFiles."/luks-hw-password".source = pkgs.luks-hw-password;
luks.devices =
mapAttrs (name: value: {
device = value;
keyFile = "/keys/${name}.key";
fallbackToPassword = true;
preOpenCommands = ''
mkdir -p /keys
/luks-hw-password/bin/luks-hw-password > /keys/${name}.key
'';
postOpenCommands = ''
rm -rf /keys
'';
})
cnf;
};
};
}
|