main
 1# Generate SSH config for Boox (osaka) Termux
 2# Usage: nix eval --raw -f android/boox/generate-ssh-config.nix
 3# Or:    make boox/ssh-config
 4let
 5  pkgs = import <nixpkgs> { };
 6  lib = pkgs.lib;
 7  globals = import ../../globals.nix { };
 8
 9  # Generate host entries from globals.machines
10  # Only VPN hosts (Boox connects via WireGuard, not LAN)
11  hostEntries = lib.concatStrings (
12    lib.attrsets.mapAttrsToList (
13      _name: machine:
14      let
15        vpnIps = lib.attrsets.attrByPath [ "net" "vpn" "ips" ] [ ] machine;
16        names = lib.attrsets.attrByPath [ "net" "names" ] [ ] machine;
17        vpnNames = builtins.filter (n: lib.strings.hasSuffix ".vpn" n) names;
18        sbrNames = builtins.filter (n: lib.strings.hasSuffix ".sbr.pm" n) names;
19        homeNames = builtins.filter (n: lib.strings.hasSuffix ".home" n) names;
20      in
21      lib.optionalString (vpnIps != [ ]) (
22        lib.concatStrings (
23          # VPN entries
24          map (n: ''
25
26            Host ${n}
27                HostName ${builtins.head vpnIps}
28                User vincent
29          '') vpnNames
30          # .sbr.pm entries (use DNS)
31          ++ map (n: ''
32
33            Host ${n}
34                HostName ${n}
35                User vincent
36          '') sbrNames
37          # .home entries (LAN IP)
38          ++ lib.optionals (lib.attrsets.attrByPath [ "net" "ips" ] [ ] machine != [ ]) (
39            map (n: ''
40
41              Host ${n}
42                  HostName ${builtins.head machine.net.ips}
43                  User vincent
44            '') homeNames
45          )
46        )
47      )
48    ) globals.machines
49  );
50in
51''
52  # Boox (osaka) SSH config  auto-generated from globals.nix
53  # Do not edit manually! Regenerate with: make boox/ssh-config
54  #
55  # Generated entries: VPN, LAN, and .sbr.pm hosts
56
57  Host *
58      ServerAliveInterval 60
59      AddKeysToAgent yes
60      IdentityFile ~/.ssh/id_ed25519
61      StrictHostKeyChecking accept-new
62
63  # === Homelab ===
64  ${hostEntries}
65  # === Git forges ===
66
67  Host github.com
68      User git
69      IdentityFile ~/.ssh/id_ed25519
70
71  Host gitlab.com
72      User git
73      IdentityFile ~/.ssh/id_ed25519
74
75  Host codeberg.org
76      User git
77      IdentityFile ~/.ssh/id_ed25519
78''