|
1 | 1 | { config, lib, pkgs, ... }: |
2 | | -let |
3 | | - inherit (lib) |
4 | | - mkEnableOption |
5 | | - mkOption |
6 | | - types; |
7 | | - inherit (config.uwumarie.profiles.ssh) |
8 | | - defaultIdentityFile |
9 | | - hosts; |
10 | | -in |
11 | 2 | { |
12 | 3 | options.uwumarie.profiles.ssh = { |
13 | | - enable = mkEnableOption "ssh config"; |
14 | | - defaultIdentityFile = mkOption { |
15 | | - type = types.str; |
| 4 | + enable = lib.mkEnableOption (lib.mdDoc "ssh config"); |
| 5 | + githubKeyFile = lib.mkOption { |
| 6 | + type = lib.types.str; |
| 7 | + default = "~/.ssh/github.ed25519"; |
16 | 8 | }; |
17 | | - hosts = mkOption { |
18 | | - type = with types; attrsOf (submodule ({ config, name, ... }: { |
19 | | - options = { |
20 | | - match = mkOption { |
21 | | - type = types.str; |
22 | | - default = name; |
23 | | - }; |
24 | | - hostname = mkOption { |
25 | | - type = types.str; |
26 | | - default = config.match; |
27 | | - }; |
28 | | - user = mkOption { |
29 | | - type = with types; nullOr str; |
30 | | - }; |
31 | | - identitiesOnly = mkOption { |
32 | | - type = types.bool; |
33 | | - default = true; |
34 | | - }; |
35 | | - identityFile = mkOption { |
36 | | - type = types.str; |
37 | | - default = defaultIdentityFile; |
38 | | - }; |
39 | | - }; |
40 | | - })); |
| 9 | + defaultKeyFile = lib.mkOption { |
| 10 | + type = lib.types.str; |
| 11 | + default = "~/.ssh/default.ed25519"; |
41 | 12 | }; |
42 | 13 | }; |
43 | 14 | config = lib.mkIf config.uwumarie.profiles.ssh.enable { |
44 | | - services.ssh-agent.enable = lib.mkDefault true; |
45 | 15 | programs.ssh = { |
46 | 16 | enable = true; |
47 | 17 | package = pkgs.openssh; |
48 | | - matchBlocks = lib.mapAttrs' (_: value: lib.nameValuePair value.match value) hosts; |
| 18 | + matchBlocks = { |
| 19 | + "github.com" = { |
| 20 | + user = "git"; |
| 21 | + identitiesOnly = true; |
| 22 | + identityFile = config.uwumarie.profiles.ssh.githubKeyFile; |
| 23 | + }; |
| 24 | + artemis = { |
| 25 | + hostname = "nue01.marie.cologne"; |
| 26 | + identitiesOnly = true; |
| 27 | + identityFile = config.uwumarie.profiles.ssh.defaultKeyFile; |
| 28 | + }; |
| 29 | + delphi = { |
| 30 | + hostname = "oci-fra01.marie.cologne"; |
| 31 | + identitiesOnly = true; |
| 32 | + identityFile = config.uwumarie.profiles.ssh.defaultKeyFile; |
| 33 | + }; |
| 34 | + raspberrypi = { |
| 35 | + user = "pi"; |
| 36 | + identityFile = config.uwumarie.profiles.ssh.defaultKeyFile; |
| 37 | + identitiesOnly = true; |
| 38 | + }; |
| 39 | + wg-nas = { |
| 40 | + hostname = "10.69.0.8"; |
| 41 | + identityFile = config.uwumarie.profiles.ssh.defaultKeyFile; |
| 42 | + identitiesOnly = true; |
| 43 | + }; |
| 44 | + gitlabber = { |
| 45 | + hostname = "warpgate.jemand771.net"; |
| 46 | + user = "marie:gitlabber"; |
| 47 | + identitiesOnly = true; |
| 48 | + }; |
| 49 | + "*" = { |
| 50 | + extraOptions = { |
| 51 | + AddKeysToAgent = "yes"; |
| 52 | + }; |
| 53 | + }; |
| 54 | + }; |
49 | 55 | }; |
| 56 | + services.ssh-agent.enable = lib.mkDefault true; |
50 | 57 | }; |
51 | 58 | } |
0 commit comments