1 { lib, config, hostName, ... }:
6 secrets = lib.mkOption {
7 type = types.attrsOf types.str;
10 Map some secrets for the initrd.
13 install = lib.mkOption {
17 Script to decrypt and send some secrets for the initrd.
20 stage1Dir = lib.mkOption {
22 default = "/run/initrd-secrets";
24 Where to store the secrets in the stage1
25 for `boot.initrd.secrets` to install them in the initrd.
28 # Alas, nixos/modules/system/boot/initrd-ssh.nix
29 # forces stage2Dir == stage1Dir
30 stage2Dir = lib.mkOption {
32 default = "/run/initrd-secrets";
34 Where to store the secrets in the stage2
35 for `boot.initrd.secrets` to retrieve them when rebuilding the system.
41 security.initrd.install =
42 lib.concatStringsSep "\n" (lib.mapAttrsToList
44 gpg --decrypt "${src}" |
45 ssh "${config.install.target}" \
46 install -D -m 400 -o root -g root /dev/stdin "${config.security.initrd.stage2Dir}/${dst}"
48 config.security.initrd.secrets
50 boot.initrd.secrets = mapAttrs'
53 "${config.security.initrd.stage1Dir}/${dst}"
54 "${config.security.initrd.stage2Dir}/${dst}"
56 config.security.initrd.secrets;