diff options
| -rw-r--r-- | flake.lock | 19 | ||||
| -rw-r--r-- | flake.nix | 5 | ||||
| -rw-r--r-- | hosts.toml | 2 | ||||
| -rw-r--r-- | hosts/mercury/config.nix | 2 | ||||
| -rw-r--r-- | hosts/mercury/hjem.nix | 2 | ||||
| -rw-r--r-- | hosts/mercury/nixos.nix | 18 | ||||
| -rw-r--r-- | modules/nix/nixos/default.nix | 3 | ||||
| -rw-r--r-- | modules/services/nixos/ssh.nix | 2 | ||||
| -rw-r--r-- | modules/user/nixos/default.nix | 13 | ||||
| -rw-r--r-- | pkgs/yoshi.nix | 53 |
10 files changed, 100 insertions, 19 deletions
@@ -392,7 +392,8 @@ "nixos-facter-modules": "nixos-facter-modules", "nixpkgs": "nixpkgs", "nmd": "nmd", - "tmux-tsunami": "tmux-tsunami" + "tmux-tsunami": "tmux-tsunami", + "yoshi-lua": "yoshi-lua" } }, "rust-overlay": { @@ -544,6 +545,22 @@ "repo": "flake-utils", "type": "github" } + }, + "yoshi-lua": { + "flake": false, + "locked": { + "lastModified": 1769401156, + "narHash": "sha256-FkxS0bSSRY4dRouDgfRRuAHl6CosYPZVjf0rtD5XxSs=", + "owner": "bluedragon1221", + "repo": "yoshi", + "rev": "fb109139eb6ddc77c9703b3f0e0047bbdde3c03b", + "type": "github" + }, + "original": { + "owner": "bluedragon1221", + "repo": "yoshi", + "type": "github" + } } }, "root": "root", @@ -38,6 +38,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + yoshi-lua = { + url = "github:bluedragon1221/yoshi"; + flake = false; + }; + firefox-csshacks = { url = "github:MrOtherGuy/firefox-csshacks"; flake = false; @@ -3,6 +3,7 @@ user_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAvxtKW0rmRBi8J67gLrLv8Zv338A host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQtMAgPdWwrOzlZT/lEIRQZ+ajhafG9AEJCrF2/bsmN" [hosts.ganymede] +hostnames = ["ganymede", "192.168.50.2", "williamsfam.us.com"] user_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFeAsRh11Jyv+7Fm4WhzV4XN0LMYQS1/yMbvT+pvFDcd collin@ganymede" host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINlr+53UmlGVP1blkdNl6NFqn1w2umFJyjH1EVUPKIy9" @@ -10,4 +11,5 @@ host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINlr+53UmlGVP1blkdNl6NFqn1w2u host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPB7feUHl5qoD5zF9AMOV2meViA+wZYdVvbVjPkggZf8" [hosts.io] +hostnames = ["io", "192.168.50.3"] host_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJXSvoVpMh/Y84THjKAYqkbuPmmv/yIU8DunMov7tKKT" diff --git a/hosts/mercury/config.nix b/hosts/mercury/config.nix index e5e0b17..b122e5e 100644 --- a/hosts/mercury/config.nix +++ b/hosts/mercury/config.nix @@ -62,7 +62,7 @@ tmux.enable = true; lazygit.enable = true; - nh.enable = true; + # nh.enable = true; git = { enable = true; userName = "Collin Williams"; diff --git a/hosts/mercury/hjem.nix b/hosts/mercury/hjem.nix index 72026c5..cc6034d 100644 --- a/hosts/mercury/hjem.nix +++ b/hosts/mercury/hjem.nix @@ -22,6 +22,8 @@ captive-browser # https://words.filippo.io/captive-browser inputs.glide-browser.packages."x86_64-linux".default + + (pkgs.callPackage ../../pkgs/yoshi.nix {inherit inputs;}) ]; files.".config/captive-browser.toml".text = '' diff --git a/hosts/mercury/nixos.nix b/hosts/mercury/nixos.nix index 6d269fe..da8b647 100644 --- a/hosts/mercury/nixos.nix +++ b/hosts/mercury/nixos.nix @@ -33,21 +33,21 @@ programs.ssh.extraConfig = '' Host ganymede - HostName williamsfam.us.com - User collin - IdentityFile /home/collin/.ssh/id_ed25519 LocalForward 8010 127.0.0.1:8010 + + Match host ganymede !exec "nc -z -w1 192.168.50.2 2222" + HostName williamsfam.us.com + Port 22 DynamicForward 9090 - Host ganymede-deploy - HostName 192.168.0.2 - User root - IdentityFile /home/collin/.ssh/id_ed25519 + Match host ganymede exec "nc -z -w1 192.168.50.2 2222" + HostName 192.168.50.2 + Port 2222 Host io Hostname 192.168.50.3 - User admin - IdentityFile /home/collin/.ssh/id_ed25519 + + Match host io !exec "nc -z -w1 192.168.50.3 22" ProxyJump ganymede ''; } diff --git a/modules/nix/nixos/default.nix b/modules/nix/nixos/default.nix index c817859..3aa8930 100644 --- a/modules/nix/nixos/default.nix +++ b/modules/nix/nixos/default.nix @@ -1,5 +1,6 @@ { config, + lib, pkgs, ... }: { @@ -22,7 +23,7 @@ nixpkgs.config.allowUnfree = true; - programs.nh = { + programs.nh = lib.mkIf config.collinux.terminal.programs.nh.enable { enable = true; flake = "/home/${config.collinux.user.name}/nixos"; clean.enable = true; diff --git a/modules/services/nixos/ssh.nix b/modules/services/nixos/ssh.nix index 23f8fc5..fa8b2ef 100644 --- a/modules/services/nixos/ssh.nix +++ b/modules/services/nixos/ssh.nix @@ -41,8 +41,6 @@ in { AuthenticationMethods = "publickey,keyboard-interactive:pam"; }; - knownHosts = builtins.mapAttrs (_: data: {publicKey = data.host_pubkey;}) hosts; - extraConfig = '' Match LocalPort 2222 AuthenticationMethods publickey diff --git a/modules/user/nixos/default.nix b/modules/user/nixos/default.nix index 7fbacd1..5a871af 100644 --- a/modules/user/nixos/default.nix +++ b/modules/user/nixos/default.nix @@ -29,11 +29,14 @@ in { programs.ssh = { systemd-ssh-proxy.enable = false; - knownHosts = builtins.mapAttrs (_: data: {publicKey = data.host_pubkey;}) hosts; - - extraConfig = '' - StrictHostKeyChecking accept-new - ''; + knownHosts = builtins.mapAttrs (_: data: + { + publicKey = data.host_pubkey; + } + // (lib.optionalAttrs (data ? hostnames) { + hostNames = data.hostnames; + })) + hosts; }; hjem = { diff --git a/pkgs/yoshi.nix b/pkgs/yoshi.nix new file mode 100644 index 0000000..14341a0 --- /dev/null +++ b/pkgs/yoshi.nix @@ -0,0 +1,53 @@ +{ + pkgs, + inputs, + ... +}: let + yossh = + pkgs.writeText "yossh.lua" + # lua + '' + yoshi = dofile'${inputs.yoshi-lua}/yoshi.lua' + + local function isHome() + local _, _, code = os.execute("nc -z -w1 192.168.50.2 2222") + return code == 0 + end + + yoshi.hosts["ganymede"] = function() + if isHome() then + return yoshi.ssh{ + HostName = "192.168.50.2", + Port = 2222, + LocalForward = 8010 + } + else + return yoshi.ssh{ + HostName = "williamsfam.us.com", + LocalForward = 8010, + DynamicFoward = 9090 + } + end + end + + yoshi.hosts["io"] = function() + if isHome() then + return yoshi.ssh{ + HostName = "192.168.50.3", + User = "admin", + } + else + return yoshi.ssh{ + HostName = "192.168.50.3", + User = "admin", + ProxyJump = "collin@ganymede", + } + end + end + + yoshi.run(arg) + ''; +in + pkgs.writeShellScriptBin "yossh" '' + exec ${pkgs.lua}/bin/lua ${yossh} "$@" + '' |
