diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2021-08-03 17:12:41 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2021-08-03 17:12:41 +0200 |
| commit | 02a0b57551a6a5f9ebccff226c12b8f671a7c149 (patch) | |
| tree | 17aacfdc9a7572b56c0bda2cd2eee6e46e950616 /system-profiles/initrd-ssh/default.nix | |
| parent | f06a55f31684b546734a4efb761a649225bb61a5 (diff) | |
| download | nixos-02a0b57551a6a5f9ebccff226c12b8f671a7c149.tar nixos-02a0b57551a6a5f9ebccff226c12b8f671a7c149.tar.gz nixos-02a0b57551a6a5f9ebccff226c12b8f671a7c149.tar.bz2 nixos-02a0b57551a6a5f9ebccff226c12b8f671a7c149.tar.xz nixos-02a0b57551a6a5f9ebccff226c12b8f671a7c149.zip | |
vidhar: initrd ssh
Diffstat (limited to 'system-profiles/initrd-ssh/default.nix')
| -rw-r--r-- | system-profiles/initrd-ssh/default.nix | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/system-profiles/initrd-ssh/default.nix b/system-profiles/initrd-ssh/default.nix new file mode 100644 index 00000000..00fa55b6 --- /dev/null +++ b/system-profiles/initrd-ssh/default.nix | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | { hostName, config, pkgs, ... }: | ||
| 2 | { | ||
| 3 | config = { | ||
| 4 | boot.initrd.network = { | ||
| 5 | enable = true; | ||
| 6 | ssh = { | ||
| 7 | enable = true; | ||
| 8 | hostKeys = with config.sops.secrets; [ initrd_ssh_host_rsa_key.path initrd_ssh_host_ed25519_key.path ]; | ||
| 9 | authorizedKeys = config.users.users.root.openssh.authorizedKeys.keys ++ map (kF: builtins.readFile kF) config.users.users.root.openssh.authorizedKeys.keyFiles; | ||
| 10 | }; | ||
| 11 | }; | ||
| 12 | |||
| 13 | sops.secrets = { | ||
| 14 | initrd_ssh_host_rsa_key = { | ||
| 15 | key = "rsa"; | ||
| 16 | path = "/etc/initrd_ssh_host_rsa_key"; | ||
| 17 | sopsFile = ./host-keys + "/${hostName}-private.yaml"; | ||
| 18 | }; | ||
| 19 | initrd_ssh_host_ed25519_key = { | ||
| 20 | key = "ed25519"; | ||
| 21 | path = "/etc/initrd_ssh_host_ed25519_key"; | ||
| 22 | sopsFile = ./host-keys + "/${hostName}-private.yaml"; | ||
| 23 | }; | ||
| 24 | }; | ||
| 25 | environment.etc = | ||
| 26 | let | ||
| 27 | mkPubkey = typ: pkgs.runCommand "initrd_ssh_host_${typ}_key" { buildInputs = with pkgs; [ yq ]; } '' | ||
| 28 | yq -r '.${typ}' ${./host-keys + "/${hostName}-public.yaml"} > $out | ||
| 29 | ''; | ||
| 30 | in { | ||
| 31 | "initrd_ssh_host_rsa_key.pub".source = mkPubkey "rsa"; | ||
| 32 | "initrd_ssh_host_ed25519_key.pub".source = mkPubkey "ed25519"; | ||
| 33 | }; | ||
| 34 | }; | ||
| 35 | } | ||
