diff options
author | Karel Kočí <cynerd@email.cz> | 2022-06-27 21:55:07 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2022-06-27 22:03:38 +0200 |
commit | 16dba0e7e389319cec6967e628d85837f5d46915 (patch) | |
tree | 6c8d09d1ff6c2c79d8406635f81f561bbf97c7a4 /nixos/modules/autounlock.nix | |
parent | dbfa517f33ab35f78d8dc3f246aa0078d3db8e05 (diff) | |
download | nixos-personal-16dba0e7e389319cec6967e628d85837f5d46915.tar.gz nixos-personal-16dba0e7e389319cec6967e628d85837f5d46915.tar.bz2 nixos-personal-16dba0e7e389319cec6967e628d85837f5d46915.zip |
nixos/machine/ridcully: update
Diffstat (limited to 'nixos/modules/autounlock.nix')
-rw-r--r-- | nixos/modules/autounlock.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/nixos/modules/autounlock.nix b/nixos/modules/autounlock.nix new file mode 100644 index 0000000..2e40bb2 --- /dev/null +++ b/nixos/modules/autounlock.nix @@ -0,0 +1,40 @@ +{ 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."/bin/luks-password" = pkgs.luks-hw-password + "/bin/luks-hw-password"; + luks.devices = mapAttrs (name: value: { + device = value; + keyFile = "/keys/${name}.key"; + fallbackToPassword = true; + preOpenCommands = '' + mkdir -p /keys + luks-hw-password > /keys/${name}.key + ''; + postOpenCommands = '' + rm -rf /keys + ''; + }) cnf; + }; + + }; + +} |